Windows有一个cmd“查询会话”,它显示有关终端服务器上的会话信息,包括“会话名称”。
我想使用Windows API ------ LsaEnumerateLogonSessions和LsaGetLogonSessionData 来获取这些会话信息,如下所示:
int main()
{
int i = 0;
ULONG count = 0;
PLUID list = NULL;
PSECURITY_LOGON_SESSION_DATA data;
LsaEnumerateLogonSessions(&count, &list);
for (i = 0; i < (int)count; i++)
{
LsaGetLogonSessionData(&list[i], &data);
}
return 0;
}
我可以获得一个SECURITY_LOGON_SESSION_DATA结构:
typedef struct _SECURITY_LOGON_SESSION_DATA {
ULONG Size;
LUID LogonId;
LSA_UNICODE_STRING UserName;
LSA_UNICODE_STRING LogonDomain;
LSA_UNICODE_STRING AuthenticationPackage;
ULONG LogonType;
ULONG Session;
PSID Sid;
LARGE_INTEGER LogonTime;
LSA_UNICODE_STRING LogonServer;
LSA_UNICODE_STRING DnsDomainName;
LSA_UNICODE_STRING Upn;
ULONG UserFlags;
LSA_LAST_INTER_LOGON_INFO LastLogonInfo;
LSA_UNICODE_STRING LogonScript;
LSA_UNICODE_STRING ProfilePath;
LSA_UNICODE_STRING HomeDirectory;
LSA_UNICODE_STRING HomeDirectoryDrive;
LARGE_INTEGER LogoffTime;
LARGE_INTEGER KickOffTime;
LARGE_INTEGER PasswordLastSet;
LARGE_INTEGER PasswordCanChange;
LARGE_INTEGER PasswordMustChange;
} SECURITY_LOGON_SESSION_DATA, *PSECURITY_LOGON_SESSION_DATA;
但它不包含会话名称!
关于如何获得“sessonname”的任何想法?