aboutsummaryrefslogtreecommitdiff
path: root/src/ext/Util/ca/scanet.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/ext/Util/ca/scanet.cpp')
-rw-r--r--src/ext/Util/ca/scanet.cpp9
1 files changed, 7 insertions, 2 deletions
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
8 DWORD er = ERROR_SUCCESS; 8 DWORD er = ERROR_SUCCESS;
9 PDOMAIN_CONTROLLER_INFOW pDomainControllerInfo = NULL; 9 PDOMAIN_CONTROLLER_INFOW pDomainControllerInfo = NULL;
10 HRESULT hr = S_OK; 10 HRESULT hr = S_OK;
11 WCHAR pwzComputerName[MAX_COMPUTERNAME_LENGTH + 1];
12 DWORD cchComputerName = countof(pwzComputerName);
11 13
12 if (pwzDomain && *pwzDomain) 14 hr = ::GetComputerNameW(pwzComputerName, &cchComputerName);
15 ExitOnFailure(hr, "failed to obtain computer name");
16
17 if (pwzDomain && *pwzDomain && 0!=lstrcmpiW(pwzComputerName, pwzDomain) && 0!=lstrcmpiW(L".", pwzDomain))
13 { 18 {
14 er = ::DsGetDcNameW(NULL, pwzDomain, NULL, NULL, flags, &pDomainControllerInfo); 19 er = ::DsGetDcNameW(NULL, pwzDomain, NULL, NULL, flags, &pDomainControllerInfo);
15 if (RPC_S_SERVER_UNAVAILABLE == er) 20 if (RPC_S_SERVER_UNAVAILABLE == er)
@@ -21,7 +26,7 @@ HRESULT GetDomainServerName(LPCWSTR pwzDomain, LPWSTR* ppwzServerName, ULONG fla
21 if (ERROR_SUCCESS == er && pDomainControllerInfo->DomainControllerName) 26 if (ERROR_SUCCESS == er && pDomainControllerInfo->DomainControllerName)
22 { 27 {
23 // Skip the \\ prefix if present. 28 // Skip the \\ prefix if present.
24 if ('\\' == *pDomainControllerInfo->DomainControllerName && '\\' == *pDomainControllerInfo->DomainControllerName + 1) 29 if ('\\' == *pDomainControllerInfo->DomainControllerName && '\\' == *(pDomainControllerInfo->DomainControllerName + 1) )
25 { 30 {
26 hr = StrAllocString(ppwzServerName, pDomainControllerInfo->DomainControllerName + 2, 0); 31 hr = StrAllocString(ppwzServerName, pDomainControllerInfo->DomainControllerName + 2, 0);
27 } 32 }