Not illegal, but they have rules they enforce on employees and students.
If you're neither, carry freely.
However, campus police can escort you off the property and issue a trespass warning preventing you from entry back onto campus property (and can arrest you if you violate it).