When I first attended the college I'm at now, I would run into former classmates I hadn't seen in a while. And... of course, they would ask, "What are you doing here?" I did ask that by accident one time though lol, it just came out.. and it was nothing personal. Even the person responded with, "Um.. I go here?" lol. It's a pretty weird question to ask unless someone is TRULY trespassing. People do seem to just simply ask that anyway though... in what seems to be a way of asking "What's up?"
Pretty weird. I don't really ask that now. I at least tell them "Hey! Long time no see!" Or if I do say "What are you doing here?" I also add on "Getting your shopping done today?" (if that was the scenario).
That's a horrible question to ask someone on campus though. It's pretty obvious they go to school there (99% of the time, anyway). I know if I ran into someone who I know DO NOT go to my school AT ALL, then I would most likely ask "What are you doing here?" I wouldn't mean it in a negative way though, it's just simply out of curiosity.