"Why are the restrictions on 2nd Amendment Rights greater in the military?"
Because we have too many 18 year old's who can't be trusted with their own johnson's let alone weapons. Alcoholism is extremely high in the military and making it harder for Joe to get a hold of guns while drunk is probably a good thing.
The 4th Amendment limits come from the fact that the military owns everything on post. The housing is not your house. You do not pay for it, the military does. They reserve the right to ensure that you are not trashing the place. The barracks are of common use and therefor, your privacy is nonexistent. The Commander, or his designate, can conduct a check at any time. If the Commander suspects drug use, he will call in the dogs and if he finds something, he has many options on how to punish you that don't involve due process. The Commander is protected by regulations concerning command policy and military authority.
Fear the man who has one gun, for he knows how to use it.