U.S. Navy Regulation Number 0828 forbids a commanding officer to permit a representative of any foreign power to search his or her command, or to allow such a person to remove any personnel, “so long as he or she has the capacity to repel such act.”
This regulation had its origin in 1798 as a result of events on board USS Baltimore. Baltimore, under the command of Capt. Isaac Phillips, accompanied a convoy of merchantmen sailing to the West Indies to protect them from French privateers during the conflict known as the Quasi-War. When a British squadron intercepted the convoy, Phillips allowed Royal Navy officers to search Baltimore and remove some fifty seamen suspected of being British citizens. The British pressed five of the men and returned the remainder.
In the aftermath, the Secretary of the Navy cashiered Phillips and issued the directive that remains, in wording only slightly altered, in force today.