如何从Windows中的会话ID获取用户名/ SID?

时间:2015-08-02 19:48:09

标签: c++ c windows winapi

我想从会话ID值中获取用户名或SID,如何使用WinAPI从Window XP中进行操作?

2 个答案:

答案 0 :(得分:6)

您可以使用WTSQuerySessionInformation functionWTSUserName获取用户名和域WTSDomainNameWTS_INFO_CLASS

此功能早在Windows 2000中就可用。

答案 1 :(得分:2)

If you need this from a local system service then you can call WTSQueryUserToken to get user token from session ID, and then use method similar to this one to retrieve a user SID (or user/domain name) using GetTokenInformation API.

相关问题