Alexandre Julliard : advapi32: Retrieve the current user SID from the server in lookup_user_account_name.
Alexandre Julliard
julliard at winehq.org
Tue Oct 6 10:35:52 CDT 2009
Module: wine
Branch: master
Commit: 07ec73fcaa80c754591e13e02bccff06fee742fc
URL: http://source.winehq.org/git/wine.git/?a=commit;h=07ec73fcaa80c754591e13e02bccff06fee742fc
Author: Alexandre Julliard <julliard at winehq.org>
Date: Tue Oct 6 16:49:22 2009 +0200
advapi32: Retrieve the current user SID from the server in lookup_user_account_name.
---
dlls/advapi32/security.c | 30 +++++++++++++-----------------
1 files changed, 13 insertions(+), 17 deletions(-)
diff --git a/dlls/advapi32/security.c b/dlls/advapi32/security.c
index 9bb76d5..bff68a3 100644
--- a/dlls/advapi32/security.c
+++ b/dlls/advapi32/security.c
@@ -2555,30 +2555,28 @@ LookupAccountNameA(
static BOOL lookup_user_account_name(PSID Sid, PDWORD cbSid, LPWSTR ReferencedDomainName,
LPDWORD cchReferencedDomainName, PSID_NAME_USE peUse )
{
- /* Default implementation: Always return a default SID */
- SID_IDENTIFIER_AUTHORITY identifierAuthority = {SECURITY_NT_AUTHORITY};
+ char buffer[sizeof(TOKEN_USER) + sizeof(SID) + sizeof(DWORD)*SID_MAX_SUB_AUTHORITIES];
+ DWORD len = sizeof(buffer);
+ HANDLE token;
BOOL ret;
PSID pSid;
static const WCHAR dm[] = {'D','O','M','A','I','N',0};
DWORD nameLen;
LPCWSTR domainName;
- ret = AllocateAndInitializeSid(&identifierAuthority,
- 2,
- SECURITY_BUILTIN_DOMAIN_RID,
- DOMAIN_ALIAS_RID_ADMINS,
- 0, 0, 0, 0, 0, 0,
- &pSid);
-
- if (!ret)
- return FALSE;
-
- if (!RtlValidSid(pSid))
+ if (!OpenThreadToken(GetCurrentThread(), TOKEN_READ, TRUE, &token))
{
- FreeSid(pSid);
- return FALSE;
+ if (GetLastError() != ERROR_NO_TOKEN) return FALSE;
+ if (!OpenProcessToken(GetCurrentProcess(), TOKEN_READ, &token)) return FALSE;
}
+ ret = GetTokenInformation(token, TokenUser, buffer, len, &len);
+ CloseHandle( token );
+
+ if (!ret) return FALSE;
+
+ pSid = ((TOKEN_USER *)buffer)->User.Sid;
+
if (Sid != NULL && (*cbSid >= GetLengthSid(pSid)))
CopySid(*cbSid, Sid, pSid);
if (*cbSid < GetLengthSid(pSid))
@@ -2605,8 +2603,6 @@ static BOOL lookup_user_account_name(PSID Sid, PDWORD cbSid, LPWSTR ReferencedDo
if (ret)
*peUse = SidTypeUser;
- FreeSid(pSid);
-
return ret;
}
More information about the wine-cvs
mailing list