Commit 93cb78f3 authored by James Hawkins's avatar James Hawkins Committed by Alexandre Julliard

advpack: Implement IsNTAdmin.

parent 51fd7507
...@@ -4,7 +4,7 @@ SRCDIR = @srcdir@ ...@@ -4,7 +4,7 @@ SRCDIR = @srcdir@
VPATH = @srcdir@ VPATH = @srcdir@
MODULE = advpack.dll MODULE = advpack.dll
IMPORTLIB = libadvpack.$(IMPLIBEXT) IMPORTLIB = libadvpack.$(IMPLIBEXT)
IMPORTS = setupapi version user32 kernel32 ntdll IMPORTS = setupapi version user32 advapi32 kernel32 ntdll
EXTRALIBS = $(LIBUNICODE) EXTRALIBS = $(LIBUNICODE)
C_SRCS = \ C_SRCS = \
......
...@@ -221,14 +221,66 @@ HRESULT WINAPI DoInfInstall(const SETUPCOMMAND_PARAMS *setup) ...@@ -221,14 +221,66 @@ HRESULT WINAPI DoInfInstall(const SETUPCOMMAND_PARAMS *setup)
* *
* RETURNS * RETURNS
* TRUE if user has admin rights, FALSE otherwise. * TRUE if user has admin rights, FALSE otherwise.
*
* BUGS
* Unimplemented.
*/ */
BOOL WINAPI IsNTAdmin( DWORD reserved, LPDWORD pReserved ) BOOL WINAPI IsNTAdmin( DWORD reserved, LPDWORD pReserved )
{ {
FIXME("(0x%08lx, %p): stub\n", reserved, pReserved); SID_IDENTIFIER_AUTHORITY SidAuthority = {SECURITY_NT_AUTHORITY};
return TRUE; PTOKEN_GROUPS pTokenGroups;
BOOL bSidFound = FALSE;
DWORD dwSize, i;
HANDLE hToken;
PSID pSid;
TRACE("(0x%08lx, %p)\n", reserved, pReserved);
if (!OpenProcessToken(GetCurrentProcess(), TOKEN_QUERY, &hToken))
return FALSE;
if (!GetTokenInformation(hToken, TokenGroups, NULL, 0, &dwSize))
{
if (GetLastError() != ERROR_INSUFFICIENT_BUFFER)
{
CloseHandle(hToken);
return FALSE;
}
}
pTokenGroups = HeapAlloc(GetProcessHeap(), 0, dwSize);
if (!pTokenGroups)
{
CloseHandle(hToken);
return FALSE;
}
if (!GetTokenInformation(hToken, TokenGroups, pTokenGroups, dwSize, &dwSize))
{
HeapFree(GetProcessHeap(), 0, pTokenGroups);
CloseHandle(hToken);
return FALSE;
}
CloseHandle(hToken);
if (!AllocateAndInitializeSid(&SidAuthority, 2, SECURITY_BUILTIN_DOMAIN_RID,
DOMAIN_ALIAS_RID_ADMINS, 0, 0, 0, 0, 0, 0, &pSid))
{
HeapFree(GetProcessHeap(), 0, pTokenGroups);
return FALSE;
}
for (i = 0; i < pTokenGroups->GroupCount; i++)
{
if (EqualSid(pSid, pTokenGroups->Groups[i].Sid))
{
bSidFound = TRUE;
break;
}
}
HeapFree(GetProcessHeap(), 0, pTokenGroups);
FreeSid(pSid);
return bSidFound;
} }
/*********************************************************************** /***********************************************************************
......
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