advapi32: Fix CheckTokenMemberShip for primary tokens.

This commit is contained in:
Nikolay Sivov 2011-08-02 02:12:51 +04:00 committed by Alexandre Julliard
parent 01fb0fdfe0
commit 5290766ae0
2 changed files with 17 additions and 2 deletions

View File

@ -607,6 +607,19 @@ CheckTokenMembership( HANDLE token, PSID sid_to_check,
}
token = thread_token;
}
else
{
TOKEN_TYPE type;
ret = GetTokenInformation(token, TokenType, &type, sizeof(TOKEN_TYPE), &size);
if (!ret) goto exit;
if (type == TokenPrimary)
{
SetLastError(ERROR_NO_IMPERSONATION_TOKEN);
return FALSE;
}
}
ret = GetTokenInformation(token, TokenGroups, NULL, 0, &size);
if (!ret && GetLastError() != ERROR_INSUFFICIENT_BUFFER)

View File

@ -3637,21 +3637,23 @@ static void test_CheckTokenMembership(void)
return;
}
is_member = FALSE;
ret = pCheckTokenMembership(token, token_groups->Groups[i].Sid, &is_member);
ok(ret, "CheckTokenMembership failed with error %d\n", GetLastError());
ok(is_member, "CheckTokenMembership should have detected sid as member\n");
is_member = FALSE;
ret = pCheckTokenMembership(NULL, token_groups->Groups[i].Sid, &is_member);
ok(ret, "CheckTokenMembership failed with error %d\n", GetLastError());
ok(is_member, "CheckTokenMembership should have detected sid as member\n");
is_member = TRUE;
SetLastError(0xdeadbeef);
ret = pCheckTokenMembership(process_token, token_groups->Groups[i].Sid, &is_member);
todo_wine {
ok(!ret && GetLastError() == ERROR_NO_IMPERSONATION_TOKEN,
"CheckTokenMembership with process token %s with error %d\n",
ret ? "succeeded" : "failed", GetLastError());
ok(!is_member, "CheckTokenMembership should have cleared is_member\n");
}
HeapFree(GetProcessHeap(), 0, token_groups);
CloseHandle(token);