From bfaac2776a26edd859324987100d621e78db3557 Mon Sep 17 00:00:00 2001 From: James Hawkins Date: Tue, 21 Jun 2005 20:49:54 +0000 Subject: [PATCH] Implement IsTokenRestricted. --- dlls/advapi32/security.c | 34 ++++++++++++++++++++++++++++++++-- 1 file changed, 32 insertions(+), 2 deletions(-) diff --git a/dlls/advapi32/security.c b/dlls/advapi32/security.c index 1f30f11816e..0e6a3840a5a 100644 --- a/dlls/advapi32/security.c +++ b/dlls/advapi32/security.c @@ -467,9 +467,39 @@ CopySid( DWORD nDestinationSidLength, PSID pDestinationSid, PSID pSourceSid ) BOOL WINAPI IsTokenRestricted( HANDLE TokenHandle ) { - FIXME("%p - stub\n", TokenHandle); + TOKEN_GROUPS *groups; + DWORD size; + NTSTATUS status; + BOOL restricted; - return FALSE; + TRACE("(%p)\n", TokenHandle); + + status = NtQueryInformationToken(TokenHandle, TokenRestrictedSids, NULL, 0, &size); + if (status != STATUS_BUFFER_TOO_SMALL) + return FALSE; + + groups = HeapAlloc(GetProcessHeap(), 0, size); + if (!groups) + { + SetLastError(ERROR_OUTOFMEMORY); + return FALSE; + } + + status = NtQueryInformationToken(TokenHandle, TokenRestrictedSids, groups, size, &size); + if (status != STATUS_SUCCESS) + { + HeapFree(GetProcessHeap(), 0, groups); + return set_ntstatus(status); + } + + if (groups->GroupCount) + restricted = TRUE; + else + restricted = FALSE; + + HeapFree(GetProcessHeap(), 0, groups); + + return restricted; } /******************************************************************************