From 5589a8081bbeb2f449339be23684e583b6df1c81 Mon Sep 17 00:00:00 2001 From: Rob Mensching Date: Sat, 15 Oct 2022 19:53:13 -0700 Subject: Fix a couple minor bug in when adding/removing user comments Plus some code clean up so error reporting is consistent. --- src/ext/Util/ca/scauser.cpp | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) (limited to 'src/ext/Util/ca/scauser.cpp') diff --git a/src/ext/Util/ca/scauser.cpp b/src/ext/Util/ca/scauser.cpp index dc5bebba..b643a842 100644 --- a/src/ext/Util/ca/scauser.cpp +++ b/src/ext/Util/ca/scauser.cpp @@ -533,13 +533,16 @@ HRESULT ScaUserExecute( // MSDN says, if we get the above error code, try again with the "DS_FORCE_REDISCOVERY" flag er = ::DsGetDcNameW(NULL, wzDomain, NULL, NULL, DS_FORCE_REDISCOVERY, &pDomainControllerInfo); } - if (ERROR_SUCCESS == er) + if (ERROR_SUCCESS == er && pDomainControllerInfo->DomainControllerName) { - if (2 <= wcslen(pDomainControllerInfo->DomainControllerName)) + // If the \\ prefix on the queried domain was present, skip it. + if ('\\' == *pDomainControllerInfo->DomainControllerName && '\\' == *pDomainControllerInfo->DomainControllerName + 1) { - wzDomain = pDomainControllerInfo->DomainControllerName + 2; // Add 2 so that we don't get the \\ prefix. - // Pass the entire string if it is too short - // to have a \\ prefix. + wzDomain = pDomainControllerInfo->DomainControllerName + 2; + } + else + { + wzDomain = pDomainControllerInfo->DomainControllerName; } } } @@ -672,7 +675,7 @@ HRESULT ScaUserExecute( // CustomAction. hr = WcaDoDeferredAction(CUSTOM_ACTION_DECORATION(L"RemoveUser"), pwzActionData, COST_USER_DELETE); ExitOnFailure(hr, "failed to schedule RemoveUser"); - } + } ReleaseNullStr(pwzScriptKey); ReleaseNullStr(pwzActionData); -- cgit v1.2.3-55-g6feb