开发者

WIN32 - Last user to login

开发者 https://www.devze.com 2023-01-25 03:14 出处:网络
Is there a reliably way to determine the last user name to login to the system? I\'ve looked at LsaEnumerateLogonSessions() and LsaGetLogonSessionData() however they require elevation on Vista and lat

Is there a reliably way to determine the last user name to login to the system? I've looked at LsaEnumerateLogonSessions() and LsaGetLogonSessionData() however they require elevation on Vista and later (which I'm keen to avoid). WMI has the same problem (presumably it's just calling Lsa behind the scenes).

I've also looked at "SOFTWARE\Microsoft\Windows\CurrentVersion\Authentication\LogonUI\LastLoggedOnUser" in HKLM, but in testing that's unreliable and doesn't get updated.

I'm really only interested in console logons开发者_开发技巧, rather than Fast User Switching or TS logons.

I've read various articles, but have yet to come up with a good solution.


You might be able to use Audit Logon events - this requires your service to have a user access right to see the Security log, but not be a full Administrator.

Eventid 528 indicates who logged on, you'd have to find the most recent instance of this.

0

精彩评论

暂无评论...
验证码 换一张
取 消