Commit 9d9a684e authored by Aric Stewart's avatar Aric Stewart Committed by Alexandre Julliard

advapi32: Handle fully qualified account names for well known sids in LookupAccountName.

parent b540d57c
......@@ -2651,6 +2651,8 @@ BOOL WINAPI LookupAccountNameW( LPCWSTR lpSystemName, LPCWSTR lpAccountName, PSI
DWORD nameLen;
LPWSTR userName = NULL;
LPCWSTR domainName;
LPCWSTR lpAccountNamePtr;
LPCWSTR lpDomainNamePtr = NULL;
FIXME("%s %s %p %p %p %p %p - stub\n", debugstr_w(lpSystemName), debugstr_w(lpAccountName),
Sid, cbSid, ReferencedDomainName, cchReferencedDomainName, peUse);
......@@ -2667,11 +2669,22 @@ BOOL WINAPI LookupAccountNameW( LPCWSTR lpSystemName, LPCWSTR lpAccountName, PSI
}
/* Check well known SIDs first */
if ((lpAccountNamePtr = strrchrW(lpAccountName,'\\')))
{
lpAccountNamePtr++;
lpDomainNamePtr = lpAccountName;
}
else
lpAccountNamePtr = lpAccountName;
for (i = 0; i < (sizeof(ACCOUNT_SIDS) / sizeof(ACCOUNT_SIDS[0])); i++)
{
if (!strcmpiW(lpAccountName, ACCOUNT_SIDS[i].account) ||
(ACCOUNT_SIDS[i].alias && !strcmpiW(lpAccountName, ACCOUNT_SIDS[i].alias)))
/* check domain first */
if (lpDomainNamePtr && (strncmpiW(lpDomainNamePtr, ACCOUNT_SIDS[i].domain, strlenW(ACCOUNT_SIDS[i].domain)) || lpDomainNamePtr[strlenW(ACCOUNT_SIDS[i].domain)]!='\\'))
continue;
if (!strcmpiW(lpAccountNamePtr, ACCOUNT_SIDS[i].account) ||
(ACCOUNT_SIDS[i].alias && !strcmpiW(lpAccountNamePtr, ACCOUNT_SIDS[i].alias)))
{
DWORD sidLen = SECURITY_MAX_SID_SIZE;
......
......@@ -1982,6 +1982,13 @@ static void test_LookupAccountName(void)
/* case insensitivity */
check_wellknown_name("lOCAlServICE", WinLocalServiceSid);
/* fully qualified account names */
check_wellknown_name("NT AUTHORITY\\LocalService", WinLocalServiceSid);
check_wellknown_name("nt authority\\Network Service", WinNetworkServiceSid);
check_wellknown_name("nt authority test\\Network Service", 0);
check_wellknown_name("Dummy\\Network Service", 0);
check_wellknown_name("ntauthority\\Network Service", 0);
}
static void test_security_descriptor(void)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment