How do I query for all users that bought a license?
I don't think it's currently possible in as clean as manner as you'd like. I'd tackle the problem by writing a small plugin that queries the database and returns a list of user ids that match the criteria.

Remember, though, is that a license does not necessarily have a user id attached to it - a license must have either a user id or an email assigned to, so you might want to keep that in mind.