Just watch until the firearm is given back and taken out of the building
I've looked into the statute which Mr. Rosenberg quotes and, as best I can tell, it looks as though he is right in stating that the judge could not ban firearms from the public building. Minnesota Code 642.714 subd. 17 allows firearms to be banned from "private establishments", but they are obviously not in a private establishment. And then there's subd. 23 of the same code section:
This section sets forth the complete and exclusive criteria and procedures for the issuance of permits to carry and establishes their nature and scope. No sheriff, police chief, governmental unit, government official, government employee, or other person or body acting under color of law or governmental authority may change, modify, or supplement these criteria or procedures, or limit the exercise of a permit to carry.A judge is clearly a person acting under color of law or governmental authority. This appears to absolutely bar a judge from banning firearms from any place at any time.
Of course, that's insane. And before anyone starts telling me that's just the prosecutor in me speaking, I'm pretty sure anyone who has been in a courthouse when emotions are running high, on both the victim's side of the aisle and the defendant's, has been glad that no weapons were allowed. Just imagine a trial in which the victim was a 3d Street Samurai Crip and the defendant is a 7th Street Banzai Latin King. Do you think the judge should be absolutely banned from keeping members of the two sets from bringing firearms to the courthouse?
Nevertheless, I couldn't find an exception to the law. That doesn't mean there isn't one somewhere, just that I couldn't find it in the statute or the case law addressing the statute. So, as far as I can tell the judge was wrong to banish firearms from the building.
On the other hand, consider the officer's situation. He has an order from a judge banning firearms. The judge is higher on the food chain than the officer. The officer is going to obey the command of the judge. So, it's no surprise that he acted to enforce the judge's order.
What's the solution here? In Virginia the technically correct solution is go over the judge's head and get an order of mandamus requiring the judge to withdraw his order or an order of prohibition to keep the judge from enforcing the order. However, this is time consuming and not practical for someone who is not going into the building often. In this case you could run up and punch the bear in the nose, trusting that he won't figure out how to get free of the chains and maul you.