Actually this is not true. Eventually the leader of the danites turned on the lds leadership in court. Joseph Smith referred to the danites as a secret combination.
Purpose
The Danites were led by Dr. Sampson Avard, and the group appears to have been formally formed about the time that Sidney Rigdon gave his “Salt Sermon” in Far West, in which he gave apostates an ultimatum to get out or suffer consequences.[1] According to Avard, the original purpose of the band was to “drive from the county of Caldwell all that dissented from the Mormon church.”[2] Once the dissenters had left the country, the Danites turned their attention to defending the Saints from mobs. Avard, however, took this purpose one step further by including retaliation against those who persecuted the Saints. Thus, the Danites began operating as a vigilante group outside the law. This, unfortunately, included stealing and plundering from those who stole and plundered from the Saints.[3] The Danites believed that if they consecrated plundered goods to the Church, that they would be protected in battle.[4] The group held secret meetings, with special signs used to identify themselves to one another.
en.fairmormon.org/Danites