I had the same problem but found a somewhat awkward solution. Instead of querying the users directly, I first check for sessions. Then I check whether there uis a session whose sessionname begins with "rdp-tcp#' or is simply empty.
If so, it means that there is at least one loggedon user. After that I query for all users on the same server. If there is no such hit, I simply return a differnt value.