https://git.reactos.org/?p=reactos.git;a=commitdiff;h=3d5c682cd8b620651e183…
commit 3d5c682cd8b620651e1838fbdec7ea0243bac412
Author: Eric Kohl <eric.kohl(a)reactos.org>
AuthorDate: Sat Aug 24 13:15:41 2019 +0200
Commit: Eric Kohl <eric.kohl(a)reactos.org>
CommitDate: Sat Aug 24 13:15:41 2019 +0200
[NETAPI32] Implement DsGetSiteNameA
Also add the NetpAllocAnsiStrFromWStr helper function.
---
dll/win32/netapi32/misc.c | 32 ++++++++++++++++++++++++++++++++
dll/win32/netapi32/netapi32.h | 5 +++++
dll/win32/netapi32/netlogon.c | 41 +++++++++++++++++++++++++++++++++++++----
3 files changed, 74 insertions(+), 4 deletions(-)
diff --git a/dll/win32/netapi32/misc.c b/dll/win32/netapi32/misc.c
index 5e541b693f7..129dda80484 100644
--- a/dll/win32/netapi32/misc.c
+++ b/dll/win32/netapi32/misc.c
@@ -135,6 +135,38 @@ NetUnregisterDomainNameChangeNotification(
}
+PSTR
+WINAPI
+NetpAllocAnsiStrFromWStr(
+ _In_ PWSTR InString)
+{
+ UNICODE_STRING UnicodeString;
+ ANSI_STRING AnsiString;
+ ULONG Size;
+ NET_API_STATUS NetStatus;
+ NTSTATUS Status;
+
+ RtlInitUnicodeString(&UnicodeString, InString);
+
+ Size = RtlUnicodeStringToAnsiSize(&UnicodeString);
+ NetStatus = NetApiBufferAllocate(Size,
+ (PVOID*)&AnsiString.Buffer);
+ if (NetStatus != NERR_Success)
+ return NULL;
+
+ Status = RtlUnicodeStringToAnsiString(&AnsiString,
+ &UnicodeString,
+ FALSE);
+ if (!NT_SUCCESS(Status))
+ {
+ NetApiBufferFree(AnsiString.Buffer);
+ return NULL;
+ }
+
+ return AnsiString.Buffer;
+}
+
+
PWSTR
WINAPI
NetpAllocWStrFromAnsiStr(
diff --git a/dll/win32/netapi32/netapi32.h b/dll/win32/netapi32/netapi32.h
index 7a839ef51ff..35004bba368 100644
--- a/dll/win32/netapi32/netapi32.h
+++ b/dll/win32/netapi32/netapi32.h
@@ -64,6 +64,11 @@ CopySidFromSidAndRid(
_In_ PSID SrcSid,
_In_ ULONG RelativeId);
+PSTR
+WINAPI
+NetpAllocAnsiStrFromWStr(
+ _In_ PWSTR InString);
+
PWSTR
WINAPI
NetpAllocWStrFromAnsiStr(
diff --git a/dll/win32/netapi32/netlogon.c b/dll/win32/netapi32/netlogon.c
index 98dc5c71632..fd93fad60f7 100644
--- a/dll/win32/netapi32/netlogon.c
+++ b/dll/win32/netapi32/netlogon.c
@@ -604,19 +604,52 @@ DsGetForestTrustInformationW(
DWORD
WINAPI
DsGetSiteNameA(
- _In_ LPCSTR ComputerName,
+ _In_opt_ LPCSTR ComputerName,
_Out_ LPSTR *SiteName)
{
- FIXME("DsGetSiteNameA(%s, %p)\n",
+ PWSTR pComputerNameW = NULL;
+ PWSTR pSiteNameW = NULL;
+ DWORD dwError = ERROR_SUCCESS;
+
+ TRACE("DsGetSiteNameA(%s, %p)\n",
debugstr_a(ComputerName), SiteName);
- return ERROR_CALL_NOT_IMPLEMENTED;
+
+ if (ComputerName != NULL)
+ {
+ pComputerNameW = NetpAllocWStrFromAnsiStr((PSTR)ComputerName);
+ if (pComputerNameW == NULL)
+ {
+ dwError = ERROR_NOT_ENOUGH_MEMORY;
+ goto done;
+ }
+ }
+
+ dwError = DsGetSiteNameW(pComputerNameW,
+ &pSiteNameW);
+ if (dwError != ERROR_SUCCESS)
+ goto done;
+
+ *SiteName = NetpAllocAnsiStrFromWStr(pSiteNameW);
+ if (*SiteName == NULL)
+ {
+ dwError = ERROR_NOT_ENOUGH_MEMORY;
+ }
+
+done:
+ if (pSiteNameW != NULL)
+ NetApiBufferFree(pSiteNameW);
+
+ if (pComputerNameW != NULL)
+ NetApiBufferFree(pComputerNameW);
+
+ return dwError;
}
DWORD
WINAPI
DsGetSiteNameW(
- _In_ LPCWSTR ComputerName,
+ _In_opt_ LPCWSTR ComputerName,
_Out_ LPWSTR *SiteName)
{
NET_API_STATUS status;