How to determine if an LSA session is active in Windows XP

I am trying to get a list of users who are currently logged in.

On Windows 7, I can call LsaEnumerateLogonSessions, then WTSQuerySessionInformation with WTSConnectState.

But in XP, each LSA session has 0 for the TS session field (if it is not a remote desktop session), which always has a WTSConnectState from WTSActive, and as a result I list all the people who have already left the machine, WTSQuerySessionInformation does not work when the session is remote desktop.

+4
source share
3 answers

I believe this code article uses a workaround, which may be what you need, it lists all running processes by checking AuthenticationId (TokenStatistics on the process token) against the LUID list LsaEnumerateLogonSessions gives you. This allows you to filter out obsolete LUIDs.

+2
source

Have you tried the WMI class Win32_loggedOnUser .

+2
source

I think,

I am trying to get a list of users who are currently logged in.

you want to list all users who are registered online, that is, have a desktop, etc. So this is the physical console and RDP connections.

So, you have to distinguish between "logged in interactively" and "logged in" due to a call to LogonUser . With LogonUser you can start a process in an interactive user session or start a batch process. LSA returns all these users.

Use WTSEnumerateSessions and check if the session is in the state you need.

+1
source

Source: https://habr.com/ru/post/1300361/


All Articles