33 bool win32_security::GetUserAndDomainName(astring &UserName, astring &DomainName)
41 #define MY_BUFSIZE 512
42 UCHAR InfoBuffer[ MY_BUFSIZE + 1 ];
43 DWORD cbInfoBuffer = MY_BUFSIZE;
55 if(GetLastError() == ERROR_NO_TOKEN) {
78 bSuccess = GetTokenInformation( hToken,
85 if(GetLastError() == ERROR_INSUFFICIENT_BUFFER) {
107 TCHAR User[MY_BUFSIZE + 1];;
108 DWORD cchUserName = MY_BUFSIZE;
109 TCHAR Domain[MY_BUFSIZE + 1];
110 DWORD cchDomainName = MY_BUFSIZE;
112 bSuccess = LookupAccountSid(NULL,
113 ((PTOKEN_USER)InfoBuffer)->User.Sid,
122 UserName = from_unicode_temp(User);
123 DomainName = from_unicode_temp(Domain);
129 astring win32_security::full_user()
131 astring user, temp_domain;
132 GetUserAndDomainName(user, temp_domain);
133 user += astring(
"[") + temp_domain +
"]";
Support for unicode builds.