From: Maxim Karasev mxkrsv@etersoft.ru
--- dlls/secur32/secur32.c | 47 +++++++++++++++++++++++++++++++++++++++++- 1 file changed, 46 insertions(+), 1 deletion(-)
diff --git a/dlls/secur32/secur32.c b/dlls/secur32/secur32.c index beb52d7d6da..1b1a91950bb 100644 --- a/dlls/secur32/secur32.c +++ b/dlls/secur32/secur32.c @@ -1153,12 +1153,57 @@ BOOLEAN WINAPI GetUserNameExW( return TRUE; }
+ case NameUserPrincipal: + { + WCHAR *output; + DWORD len = 0; + BOOL status; + DWORD username_len = UNLEN + 1; + + status = GetComputerNameExW(ComputerNameDnsFullyQualified, NULL, &len); + if (status || GetLastError() != ERROR_MORE_DATA) + { + ERR("GetComputerNameExW expected ERROR_MORE_DATA, error %lu\n", GetLastError()); + return FALSE; + } + + output = HeapAlloc(GetProcessHeap(), 0, sizeof(WCHAR) * (username_len + 1 + len)); + + status = GetUserNameW(output, &username_len); + if (!status) + { + ERR("GetUserNameW failed, error %lu\n", GetLastError()); + return FALSE; + } + + wcscat(output, L"@"); + + status = GetComputerNameExW(ComputerNameDnsFullyQualified, &output[wcslen(output)], &len); + if (!status) + { + ERR("GetComputerNameExW failed, error %lu\n", GetLastError()); + return FALSE; + } + + if (lstrlenW(output) >= *nSize) + { + TRACE("Output buffer too small\n"); + SetLastError(ERROR_MORE_DATA); + *nSize = lstrlenW(output) + 1; + return FALSE; + } + + lstrcpyW(lpNameBuffer, output); + *nSize = lstrlenW(output); + + return TRUE; + } + case NameUnknown: case NameFullyQualifiedDN: case NameDisplay: case NameUniqueId: case NameCanonical: - case NameUserPrincipal: case NameCanonicalEx: case NameServicePrincipal: case NameDnsDomain: