Code:
18 U.S.C. ยง 930 : US Code - Section 930: Possession of firearms and dangerous
weapons in Federal facilities
(a) Except as provided in subsection (d),...
(d) Subsection (a) shall not apply to.....
(3) the lawful carrying of firearms or other dangerous weapons
in a Federal facility incident to hunting or other lawful
purposes.
As a Commander, the hunting part is clear, at my discretion, and for the most part generally supported here at Belvoir as it has at
every [large] base I'd ever been posted to.
Now "the other lawful purposes" part I also take to be at my [commander's] discretion to invoke orders having the power of law (i.e., lawful), and generally covers military members taking personal weapons to-and-fro/on-base to off-base to/from open post ranges and/or sanctioned events or locations (etc, etc, etc)
While a commander's orders have the power of law over military personnel, as a commander I would assume the prerogative of detaining civilian personnel found in violation (depending on circumstances) and let the marshals and federal court sort it out.
So far (and that's a question mark again), the courts have agreed with that implementation.
Until the courts do not, that's de facto law.
And as Peetzakilla notes, I wouldn't test it myself.