From 8f5130afdc60f4957086e41d62cfe9f8d70d5321 Mon Sep 17 00:00:00 2001 From: Bevan Weiss Date: Fri, 3 Jan 2025 15:06:15 +1100 Subject: Fix ups for Domain Group creation / removal. Signed-off-by: Bevan Weiss --- src/ext/Util/ca/scanet.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'src/ext/Util/ca/scanet.cpp') diff --git a/src/ext/Util/ca/scanet.cpp b/src/ext/Util/ca/scanet.cpp index a8ad0316..ad6c8b01 100644 --- a/src/ext/Util/ca/scanet.cpp +++ b/src/ext/Util/ca/scanet.cpp @@ -8,8 +8,13 @@ HRESULT GetDomainServerName(LPCWSTR pwzDomain, LPWSTR* ppwzServerName, ULONG fla DWORD er = ERROR_SUCCESS; PDOMAIN_CONTROLLER_INFOW pDomainControllerInfo = NULL; HRESULT hr = S_OK; + WCHAR pwzComputerName[MAX_COMPUTERNAME_LENGTH + 1]; + DWORD cchComputerName = countof(pwzComputerName); - if (pwzDomain && *pwzDomain) + hr = ::GetComputerNameW(pwzComputerName, &cchComputerName); + ExitOnFailure(hr, "failed to obtain computer name"); + + if (pwzDomain && *pwzDomain && 0!=lstrcmpiW(pwzComputerName, pwzDomain) && 0!=lstrcmpiW(L".", pwzDomain)) { er = ::DsGetDcNameW(NULL, pwzDomain, NULL, NULL, flags, &pDomainControllerInfo); if (RPC_S_SERVER_UNAVAILABLE == er) @@ -21,7 +26,7 @@ HRESULT GetDomainServerName(LPCWSTR pwzDomain, LPWSTR* ppwzServerName, ULONG fla if (ERROR_SUCCESS == er && pDomainControllerInfo->DomainControllerName) { // Skip the \\ prefix if present. - if ('\\' == *pDomainControllerInfo->DomainControllerName && '\\' == *pDomainControllerInfo->DomainControllerName + 1) + if ('\\' == *pDomainControllerInfo->DomainControllerName && '\\' == *(pDomainControllerInfo->DomainControllerName + 1) ) { hr = StrAllocString(ppwzServerName, pDomainControllerInfo->DomainControllerName + 2, 0); } -- cgit v1.2.3-55-g6feb