Well they ARE allowed to serve in the military....
Where the Posse Comitatus law prevents them from being used as ordinary police.
Only legal residents can serve in the military. Work visa, no.