Ever wonder what are considered the exceptions to the First Amendment? Take particular note of the 'time, place, and manner' restrictions. Also, the government can tie conditions to federal funds. Therefore, a university that does not allow the military to recruit on campus would forfeit their monies.
Open CRS Network - CRS Reports for the People:Freedom of Speech and Press: Exceptions to the First Amendment(PDF)