mirror of
https://github.com/reactos/reactos.git
synced 2025-08-05 00:45:43 +00:00
implemented LookupAccountSidW() thx to the help of Alex Ionescu - this function is needed for GetUserNameA/W().
svn path=/trunk/; revision=12114
This commit is contained in:
parent
a80be8cc45
commit
c3168d10e5
1 changed files with 86 additions and 30 deletions
|
@ -1,4 +1,4 @@
|
||||||
/* $Id: misc.c,v 1.30 2004/12/13 19:06:28 weiden Exp $
|
/* $Id: misc.c,v 1.31 2004/12/14 06:40:50 royce Exp $
|
||||||
*
|
*
|
||||||
* COPYRIGHT: See COPYING in the top level directory
|
* COPYRIGHT: See COPYING in the top level directory
|
||||||
* PROJECT: ReactOS system libraries
|
* PROJECT: ReactOS system libraries
|
||||||
|
@ -9,6 +9,7 @@
|
||||||
#include "advapi32.h"
|
#include "advapi32.h"
|
||||||
#include <accctrl.h>
|
#include <accctrl.h>
|
||||||
#include <malloc.h>
|
#include <malloc.h>
|
||||||
|
#include <ntsecapi.h>
|
||||||
|
|
||||||
#define NDEBUG
|
#define NDEBUG
|
||||||
#include <debug.h>
|
#include <debug.h>
|
||||||
|
@ -666,40 +667,95 @@ LookupAccountSidA (LPCSTR lpSystemName,
|
||||||
/******************************************************************************
|
/******************************************************************************
|
||||||
* LookupAccountSidW [ADVAPI32.@]
|
* LookupAccountSidW [ADVAPI32.@]
|
||||||
*
|
*
|
||||||
* @unimplemented
|
* @implemented
|
||||||
*/
|
*/
|
||||||
BOOL STDCALL
|
BOOL WINAPI
|
||||||
LookupAccountSidW (LPCWSTR lpSystemName,
|
LookupAccountSidW (
|
||||||
PSID lpSid,
|
LPCWSTR pSystemName,
|
||||||
LPWSTR lpName,
|
PSID pSid,
|
||||||
LPDWORD cchName,
|
LPWSTR pAccountName,
|
||||||
LPWSTR lpReferencedDomainName,
|
LPDWORD pdwAccountName,
|
||||||
LPDWORD cchReferencedDomainName,
|
LPWSTR pDomainName,
|
||||||
PSID_NAME_USE peUse)
|
LPDWORD pdwDomainName,
|
||||||
|
PSID_NAME_USE peUse )
|
||||||
{
|
{
|
||||||
DWORD NameLength;
|
LSA_UNICODE_STRING SystemName;
|
||||||
DWORD DomainLength;
|
LSA_OBJECT_ATTRIBUTES ObjectAttributes;
|
||||||
|
LSA_HANDLE PolicyHandle = INVALID_HANDLE_VALUE;
|
||||||
|
NTSTATUS Status;
|
||||||
|
PLSA_REFERENCED_DOMAIN_LIST ReferencedDomain = NULL;
|
||||||
|
PLSA_TRANSLATED_NAME TranslatedName = NULL;
|
||||||
|
BOOL ret;
|
||||||
|
|
||||||
DPRINT1("LookupAccountSidW is unimplemented, but returns success\n");
|
RtlInitUnicodeString ( &SystemName, pSystemName );
|
||||||
|
ZeroMemory(&ObjectAttributes, sizeof(ObjectAttributes));
|
||||||
|
Status = LsaOpenPolicy ( &SystemName, &ObjectAttributes, POLICY_LOOKUP_NAMES, &PolicyHandle );
|
||||||
|
if ( !SUCCEEDED(Status) )
|
||||||
|
{
|
||||||
|
SetLastError ( LsaNtStatusToWinError(Status) );
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
Status = LsaLookupSids ( PolicyHandle, 1, &pSid, &ReferencedDomain, &TranslatedName );
|
||||||
|
|
||||||
/* Calculate length needed */
|
LsaClose ( PolicyHandle );
|
||||||
NameLength = wcslen(L"Administrator") + sizeof(WCHAR);
|
|
||||||
DomainLength = wcslen(L"BUILTIN") + sizeof(WCHAR);
|
|
||||||
|
|
||||||
if (*cchName < NameLength || *cchReferencedDomainName < DomainLength)
|
if ( Status != 0 /* STATUS_SUCCESS */ )
|
||||||
{
|
{
|
||||||
*cchName = NameLength;
|
SetLastError ( LsaNtStatusToWinError(Status) );
|
||||||
*cchReferencedDomainName = DomainLength;
|
ret = FALSE;
|
||||||
SetLastError(ERROR_INSUFFICIENT_BUFFER);
|
}
|
||||||
return FALSE;
|
else
|
||||||
}
|
{
|
||||||
|
ret = TRUE;
|
||||||
|
if ( TranslatedName )
|
||||||
|
{
|
||||||
|
DWORD dwSrcLen = TranslatedName->Name.Length / sizeof(WCHAR);
|
||||||
|
if ( *pdwAccountName <= dwSrcLen )
|
||||||
|
{
|
||||||
|
*pdwAccountName = dwSrcLen + 1;
|
||||||
|
ret = FALSE;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
*pdwAccountName = dwSrcLen;
|
||||||
|
wcscpy ( pAccountName, TranslatedName->Name.Buffer );
|
||||||
|
}
|
||||||
|
if ( peUse )
|
||||||
|
*peUse = TranslatedName->Use;
|
||||||
|
}
|
||||||
|
|
||||||
if (lpName) lstrcpynW(lpName, L"Administrator", *cchName);
|
if ( ReferencedDomain )
|
||||||
if (lpReferencedDomainName) lstrcpynW(lpReferencedDomainName, L"BUILTIN", *cchReferencedDomainName);
|
{
|
||||||
return TRUE;
|
if ( ReferencedDomain->Entries > 0 )
|
||||||
|
{
|
||||||
|
DWORD dwSrcLen = ReferencedDomain->Domains[0].Name.Length / sizeof(WCHAR);
|
||||||
|
if ( *pdwDomainName <= dwSrcLen )
|
||||||
|
{
|
||||||
|
*pdwDomainName = dwSrcLen + 1;
|
||||||
|
ret = FALSE;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
*pdwDomainName = dwSrcLen;
|
||||||
|
wcscpy ( pDomainName, ReferencedDomain->Domains[0].Name.Buffer );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( !ret )
|
||||||
|
SetLastError(ERROR_INSUFFICIENT_BUFFER);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( ReferencedDomain )
|
||||||
|
LsaFreeMemory ( ReferencedDomain );
|
||||||
|
if ( TranslatedName )
|
||||||
|
LsaFreeMemory ( TranslatedName );
|
||||||
|
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/******************************************************************************
|
/******************************************************************************
|
||||||
* LookupAccountNameA [ADVAPI32.@]
|
* LookupAccountNameA [ADVAPI32.@]
|
||||||
*
|
*
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue