Commit 7aa3be47 authored by Ulrich Czekalla's avatar Ulrich Czekalla Committed by Alexandre Julliard

advapi32: Add partial implementation of LookupAccountNameW.

parent f7b678e8
......@@ -1775,13 +1775,50 @@ LookupAccountNameA(
IN OUT LPDWORD cbReferencedDomainName,
OUT PSID_NAME_USE name_use )
{
BOOL ret;
UNICODE_STRING lpSystemW;
UNICODE_STRING lpAccountW;
LPWSTR lpReferencedDomainNameW = NULL;
RtlCreateUnicodeStringFromAsciiz(&lpSystemW, system);
RtlCreateUnicodeStringFromAsciiz(&lpAccountW, account);
if (ReferencedDomainName)
lpReferencedDomainNameW = HeapAlloc(GetProcessHeap(), 0, *cbReferencedDomainName * sizeof(WCHAR));
ret = LookupAccountNameW(lpSystemW.Buffer, lpAccountW.Buffer, sid, cbSid, lpReferencedDomainNameW,
cbReferencedDomainName, name_use);
if (ret && lpReferencedDomainNameW)
{
WideCharToMultiByte(CP_ACP, 0, lpReferencedDomainNameW, *cbReferencedDomainName,
ReferencedDomainName, *cbReferencedDomainName, NULL, NULL);
}
RtlFreeUnicodeString(&lpSystemW);
RtlFreeUnicodeString(&lpAccountW);
if (lpReferencedDomainNameW)
HeapFree(GetProcessHeap(), 0, lpReferencedDomainNameW);
return ret;
}
/******************************************************************************
* LookupAccountNameW [ADVAPI32.@]
*/
BOOL WINAPI LookupAccountNameW( LPCWSTR lpSystemName, LPCWSTR lpAccountName, PSID Sid,
LPDWORD cbSid, LPWSTR ReferencedDomainName,
LPDWORD cchReferencedDomainName, PSID_NAME_USE peUse )
{
/* Default implementation: Always return a default SID */
SID_IDENTIFIER_AUTHORITY identifierAuthority = {SECURITY_NT_AUTHORITY};
BOOL ret;
PSID pSid;
static const char dm[] = "DOMAIN";
static const WCHAR dm[] = {'D','O','M','A','I','N'};
FIXME("(%s,%s,%p,%p,%p,%p,%p), stub.\n",system,account,sid,cbSid,ReferencedDomainName,cbReferencedDomainName,name_use);
FIXME("%s %s %p %p %p %p %p - stub\n", debugstr_w(lpSystemName), debugstr_w(lpAccountName),
Sid, cbSid, ReferencedDomainName, cchReferencedDomainName, peUse);
ret = AllocateAndInitializeSid(&identifierAuthority,
2,
......@@ -1792,14 +1829,15 @@ LookupAccountNameA(
if (!ret)
return FALSE;
if(!RtlValidSid(pSid))
if (!RtlValidSid(pSid))
{
FreeSid(pSid);
return FALSE;
}
if (sid != NULL && (*cbSid >= GetLengthSid(pSid)))
CopySid(*cbSid, sid, pSid);
if (Sid != NULL && (*cbSid >= GetLengthSid(pSid)))
CopySid(*cbSid, Sid, pSid);
if (*cbSid < GetLengthSid(pSid))
{
SetLastError(ERROR_INSUFFICIENT_BUFFER);
......@@ -1807,14 +1845,16 @@ LookupAccountNameA(
}
*cbSid = GetLengthSid(pSid);
if (ReferencedDomainName != NULL && (*cbReferencedDomainName > strlen(dm)))
strcpy(ReferencedDomainName, dm);
if (*cbReferencedDomainName <= strlen(dm))
if (ReferencedDomainName != NULL && (*cchReferencedDomainName > strlenW(dm)))
strcpyW(ReferencedDomainName, dm);
if (*cchReferencedDomainName <= strlenW(dm))
{
SetLastError(ERROR_INSUFFICIENT_BUFFER);
ret = FALSE;
}
*cbReferencedDomainName = strlen(dm)+1;
*cchReferencedDomainName = strlenW(dm)+1;
FreeSid(pSid);
......@@ -1822,19 +1862,6 @@ LookupAccountNameA(
}
/******************************************************************************
* LookupAccountNameW [ADVAPI32.@]
*/
BOOL WINAPI LookupAccountNameW( LPCWSTR lpSystemName, LPCWSTR lpAccountName, PSID Sid,
LPDWORD cbSid, LPWSTR ReferencedDomainName,
LPDWORD cchReferencedDomainName, PSID_NAME_USE peUse )
{
FIXME("%s %s %p %p %p %p %p - stub\n", debugstr_w(lpSystemName), debugstr_w(lpAccountName),
Sid, cbSid, ReferencedDomainName, cchReferencedDomainName, peUse);
return FALSE;
}
/******************************************************************************
* PrivilegeCheck [ADVAPI32.@]
*/
BOOL WINAPI PrivilegeCheck( HANDLE ClientToken, PPRIVILEGE_SET RequiredPrivileges, LPBOOL pfResult)
......
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