Search code examples
winapiwindows-serviceswindows-xpterminal-services

Getting TS session ID that user is using from LUID


I am connecting to an XP computer on a domain using remote desktop (no user is or was connected since last restart), and I can see that the applications I am using (like explorer.exe) belongs to TS session ID 0.

In the same time I am getting information using the function LsaGetLogonSessionData() in a Windows service I am running, and according to the information I get from that function, my TS session ID is 2 (for example) and NOT 0.

How can I tell in my Windows service that my login is using explorer.exe at TS session 0 if the function tells me that it is on TS session 2 ?!

I must admit that these Windows session got me REALLY confused!


I'll try to rephrase the question: How do I know on which TS session ID a LUID is using ?


Solution

  • May be due to logon session vs RDP session mismatch. Try ProcessIdToSessionId instead.