
93 S.E.2d 90 (1956)
244 N.C. 256
Clarence W. HINSHAW, Trading as Burlington Scrap Iron and Metal Company,
v.
Marvin R. McIVER, Tax Collector of Burlington.
No. 740.
Supreme Court of North Carolina.
June 6, 1956.
*92 Clarence Ross, Graham, and Cooper, Latham & Cooper, Burlington, for plaintiff-appellant.
W. D. Madry and W. R. Dalton, Jr., Burlington, for defendant-appellee.
DEVIN, Justice.
It is settled law in this jurisdiction that mandamus will lie to compel the performance of a purely ministerial duty imposed by law, and that the party seeking the writ must have a clear legal right to demand it, and the party sought to be coerced must be under legal obligation to perform the duty. Bryan v. City of Sanford, 244 N.C. 30, 92 S.E.2d 420; Nebel v. Nebel, 241 N.C. 491, 499, 85 S.E.2d 876; Harris v. Board of Education, 216 N.C. 147, 4 S.E.2d 328. "The function of the writ is to compel the performance of a ministerial dutynot to establish a legal right, but to enforce one which has been established." St. George v. Hanson, 239 N.C. 259, 78 S.E.2d 885, 888. However, the writ will not issue to compel the performance of an illegal or unauthorized act, nor will it issue where the rights of those not parties to the action would be injuriously affected. 55 C.J.S., Mandamus, § 10, pp. 35-36. It was held in Spur Distributing Co. v. City of Burlington, 216 N.C. 32, 3 S.E.2d 427, that mandamus would not lie to require issuance of building permit in violation of an ordinance.
To issue the writ as prayed for under the circumstances here made to appear would be to compel the defendant tax collector to violate the ordinances adopted by the City Council of Burlington and to disregard the orders of the Council with respect to this plaintiff's operations at the place where he had been doing business. There was no evidence that the plaintiff had complied with the orders of the Council.
It is disclosed by the admitted records that the City Council acted in accordance with the provisions and procedure set out in the ordinances which in the exercise of its police power the City had adopted, and that it heard evidence of violations of these ordinances by the plaintiff in a public hearing at which the plaintiff and his counsel were present, and found the complaints were true. Thereupon, in the exercise of the power reserved in the ordinance, it revoked the plaintiff's license and ordered his operations to cease. The ordinances and regulations under which the Council acted were in force at the time the plaintiff obtained license as junk dealer in 1954. One obtaining license under a city ordinance is ordinarily bound by the provisions of the ordinance as to revocation. State ex rel. Bluemound Amusement Park v. City of Milwaukee, 207 Wis. 199, 240 N.W. 847, 79 A.L.R. 281. The power of a municipal corporation to enact ordinances and regulations for the better government of the city is conferred by statute, G.S. § 160-200. And the power to regulate the operation of junk yards within its borders is within the police power of the city. McIntyre v. Murphy, 177 N.C. 300, 98 S.E. 820; Turner v. City of New Bern, 187 N.C. 541, 122 S.E. 469; Town of Wake Forest v. Medlin, 199 N.C. 83, 154 S.E. 29; Town of Ahoskie v. Moye, 200 N.C. 11, 156 S.E. 130.
The power to enact regulatory ordinances for the protection of the public and to prevent nuisances is not to be forestalled or foreclosed by writ of mandamus. Town of Wake Forest v. Medlin, supra. Violation of the provisions of ordinances regulating a business for which license is issued affords grounds for revoking the license, and revocation of license for failure to comply with regulations prescribed by the city ordinance is not precluded by statute *93 authorizing penalities for violation. Prawdzik v. City of Grand Rapids, 313 Mich. 376, 21 N.W.2d 168, 165 A.L.R. 1165.
Plaintiff apparently acquiesced in the action of the Council in April and May, 1955, and took no steps to review in appropriate proceedings the action of the Council, if he felt aggrieved.
Plaintiff takes the position that in any event he was entitled as a matter of law to require the tax collector to issue him license as a junk dealer, and that the ordinances relied on by the defendant are void. He cites as authority Ornoff v. City of Durham, 221 N.C. 457, 20 S.E.2d 380, but that case does not help him. In the Ornoff case the plaintiff applied to the tax collector of the City of Durham for license as a junk dealer for the year 1941. This was refused on the ground that the City had previously adopted a zoning ordinance which would prohibit use of the locality for conducting a junk business. It appeared, however, that plaintiff had been engaged in the junk business there before the adoption of the zoning ordinance and that the ordinance contained the provision that "any nonconforming use existing at the time of passage of the ordinance may be continued." The case came to the Supreme Court on appeal from the judgment in the Superior Court overruling defendants' demurrer. The ruling below was affirmed and the cause remanded for determination of the issue of fact whether plaintiff had been engaged in the junk business at that place prior to the adoption of the zoning ordinance. In that case it will be noted the City of Durham was made a party, though the validity of the city ordinance was not involved. We have examined the other authorities cited by plaintiff, but they do not militate against the conclusion we have reached on the facts of this case.
We concur in the view of the able judge who heard this case below that under the circumstances here made to appear the plaintiff has not shown a clear legal right to the relief prayed for, and that the Court would not undertake to test the validity of the ordinances and orders of the City of Burlington in an action to which the City was not a party. There was no error in denying the plaintiff's application for writ of mandamus.
Affirmed.
JOHNSON, J., not sitting.
The foregoing opinion was prepared by DEVIN, Emergency Justice, while he was serving in place of JOHNSON, J., who was absent on account of his physical condition. It is now adopted by the Court and ordered filed.
