For the NCAA, it is scored as follows (from page 10 of the 2011 Official Basketball
A.R.15. Adams throws a pass to himself or herself off the backboard, and then shoots and makes the basket. Ruling: Credit Adams with a FGA and FGM, but no assist
For the NBA, according to this Q&A (from 2009) with Bernie Fryer (Vice President of Referee Operations and Director of Officials in the NBA), it is also allowed:
Are you allowed to throw the ball off the backboard, grab your own rebound and dunk it without landing?
Bernie's answer: Yes. Under the traveling rule, a player who attempts a shot or pass may not be the first to touch the ball unless it touches the backboard, rim or another player. Therefore, a player can intentionally pass the ball to himself off the backboard or rim.
Actually, a week or so ago Kobe Bryant was double teamed near the 3-point line, had no one to pass to and had already picked up his dribble. He was about to fall down, which would have been traveling, instead he alertly threw the ball off the backboard, caught it and dribbled back to the top of the key. This wasn't an alley-oop but was similar. Michael Jordan was famous for doing the same thing on occasion.