There are two situations to consider:
In the first situation, the student has not done anything wrong. If it was a private establishment, as in Can the manager of a commercial establishment forbid someone to enter?, a manager could forbid someone to enter at his own will. But I believe this case is different.
In the second situation, the student did something wrong that, in principle, could support the decision. But the student is not informed of this reason. He is simply banned from entering the building.