I was more or less copy-pasting the solution of this question. Have customized and whatnot but the general method is the same.
The thing is, that it works like charm on all of the - tested - XP machines (don't ask, you'd be surprised)
It is also good on most of the W7 machines on desktops, notebooks through VPN and embedded models (Thin Clients) as well. The program freezes if the WMI is broken (?) but that I'll take care of later.
The painful part is that there is some sort of updater or installer service-like user. It's checking AD and such, but I don't have access to the servers to check if how it exactly works. The user is called TA2whatever looks just like an ordinary user what is slowing down the query of the logged in users, and it also gives an untrue result. The TA2 user is not only logged in once at once but 2, 10 or even 30 times at the same time. And this makes getting logged on remote users extremely slow.
The goal would be to get one logged in username (with status like locked or active if possible). I thought to get the SID and search for the registry and resolve the SID to username. Is that doable?
I haven't tried yet, but I've read that there is no NOT LIKE option in this query language. (I don't want to sound dumb so please correct me if I'm saying anything wrong)
Could something this work?
ObjectQuery Query = new ObjectQuery("SELECT LogonId FROM Win32_LogonSession Where LogonType=2 Name NOT LIKE TA2");
Or even with a set of variables if there will be more strange not real person users.
Thank you!