mirror of
https://github.com/reactos/reactos.git
synced 2025-08-05 12:43:05 +00:00
- Implement GetUserNameExA/W (code from Wine)
svn path=/trunk/; revision=40648
This commit is contained in:
parent
cf37479786
commit
3ec26577f7
1 changed files with 92 additions and 18 deletions
|
@ -21,6 +21,8 @@
|
||||||
#define NDEBUG
|
#define NDEBUG
|
||||||
#include <debug.h>
|
#include <debug.h>
|
||||||
|
|
||||||
|
#define UNLEN 256
|
||||||
|
|
||||||
|
|
||||||
/***********************************************************************
|
/***********************************************************************
|
||||||
* GetComputerObjectNameA (SECUR32.@) Wine 1.1.14
|
* GetComputerObjectNameA (SECUR32.@) Wine 1.1.14
|
||||||
|
@ -189,27 +191,99 @@ BOOLEAN WINAPI GetComputerObjectNameW(
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
BOOLEAN
|
BOOLEAN WINAPI GetUserNameExA(
|
||||||
WINAPI
|
EXTENDED_NAME_FORMAT NameFormat, LPSTR lpNameBuffer, PULONG nSize)
|
||||||
GetUserNameExA (
|
|
||||||
EXTENDED_NAME_FORMAT extended_exe_format,
|
|
||||||
LPSTR lpstr,
|
|
||||||
PULONG pulong
|
|
||||||
)
|
|
||||||
{
|
{
|
||||||
UNIMPLEMENTED;
|
BOOLEAN rc;
|
||||||
return ERROR_CALL_NOT_IMPLEMENTED;
|
LPWSTR bufferW = NULL;
|
||||||
|
ULONG sizeW = *nSize;
|
||||||
|
DPRINT("(%d %p %p)\n", NameFormat, lpNameBuffer, nSize);
|
||||||
|
if (lpNameBuffer) {
|
||||||
|
bufferW = HeapAlloc(GetProcessHeap(), 0, sizeW * sizeof(WCHAR));
|
||||||
|
if (bufferW == NULL) {
|
||||||
|
SetLastError(ERROR_NOT_ENOUGH_MEMORY);
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
rc = GetUserNameExW(NameFormat, bufferW, &sizeW);
|
||||||
|
if (rc) {
|
||||||
|
ULONG len = WideCharToMultiByte(CP_ACP, 0, bufferW, -1, NULL, 0, NULL, NULL);
|
||||||
|
if (len <= *nSize)
|
||||||
|
{
|
||||||
|
WideCharToMultiByte(CP_ACP, 0, bufferW, -1, lpNameBuffer, *nSize, NULL, NULL);
|
||||||
|
*nSize = len - 1;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
*nSize = len;
|
||||||
|
rc = FALSE;
|
||||||
|
SetLastError(ERROR_MORE_DATA);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
*nSize = sizeW;
|
||||||
|
HeapFree(GetProcessHeap(), 0, bufferW);
|
||||||
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
BOOLEAN
|
BOOLEAN WINAPI GetUserNameExW(
|
||||||
WINAPI
|
EXTENDED_NAME_FORMAT NameFormat, LPWSTR lpNameBuffer, PULONG nSize)
|
||||||
GetUserNameExW (
|
|
||||||
EXTENDED_NAME_FORMAT extended_exe_format,
|
|
||||||
LPWSTR lpstr,
|
|
||||||
PULONG pulong
|
|
||||||
)
|
|
||||||
{
|
{
|
||||||
UNIMPLEMENTED;
|
BOOLEAN status;
|
||||||
return ERROR_CALL_NOT_IMPLEMENTED;
|
WCHAR samname[UNLEN + 1 + MAX_COMPUTERNAME_LENGTH + 1];
|
||||||
|
LPWSTR out;
|
||||||
|
DWORD len;
|
||||||
|
DPRINT("(%d %p %p)\n", NameFormat, lpNameBuffer, nSize);
|
||||||
|
|
||||||
|
switch (NameFormat)
|
||||||
|
{
|
||||||
|
case NameSamCompatible:
|
||||||
|
{
|
||||||
|
/* This assumes the current user is always a local account */
|
||||||
|
len = MAX_COMPUTERNAME_LENGTH + 1;
|
||||||
|
if (GetComputerNameW(samname, &len))
|
||||||
|
{
|
||||||
|
out = samname + lstrlenW(samname);
|
||||||
|
*out++ = '\\';
|
||||||
|
len = UNLEN + 1;
|
||||||
|
if (GetUserNameW(out, &len))
|
||||||
|
{
|
||||||
|
status = (lstrlenW(samname) < *nSize);
|
||||||
|
if (status)
|
||||||
|
{
|
||||||
|
lstrcpyW(lpNameBuffer, samname);
|
||||||
|
*nSize = lstrlenW(samname);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
SetLastError(ERROR_MORE_DATA);
|
||||||
|
*nSize = lstrlenW(samname) + 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
status = FALSE;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
status = FALSE;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case NameUnknown:
|
||||||
|
case NameFullyQualifiedDN:
|
||||||
|
case NameDisplay:
|
||||||
|
case NameUniqueId:
|
||||||
|
case NameCanonical:
|
||||||
|
case NameUserPrincipal:
|
||||||
|
case NameCanonicalEx:
|
||||||
|
case NameServicePrincipal:
|
||||||
|
case NameDnsDomain:
|
||||||
|
SetLastError(ERROR_NONE_MAPPED);
|
||||||
|
status = FALSE;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
SetLastError(ERROR_INVALID_PARAMETER);
|
||||||
|
status = FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
return status;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue