summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--source3/libsmb/dsgetdcname.c25
1 files changed, 21 insertions, 4 deletions
diff --git a/source3/libsmb/dsgetdcname.c b/source3/libsmb/dsgetdcname.c
index cad212827d..bdaa250aaf 100644
--- a/source3/libsmb/dsgetdcname.c
+++ b/source3/libsmb/dsgetdcname.c
@@ -1179,12 +1179,14 @@ NTSTATUS dsgetdcname(TALLOC_CTX *mem_ctx,
struct netr_DsRGetDCNameInfo **info)
{
NTSTATUS status;
- char *query_site = NULL;
+ const char *query_site = NULL;
+ char *ptr_to_free = NULL;
if ((site_name == NULL) || (site_name[0] == '\0')) {
- query_site = sitename_fetch(domain_name);
+ ptr_to_free = sitename_fetch(domain_name);
+ query_site = ptr_to_free;
} else {
- query_site = SMB_STRDUP(site_name);
+ query_site = site_name;
}
status = dsgetdcname_internal(mem_ctx,
@@ -1195,7 +1197,22 @@ NTSTATUS dsgetdcname(TALLOC_CTX *mem_ctx,
flags,
info);
- SAFE_FREE(query_site);
+ SAFE_FREE(ptr_to_free);
+
+ if (!NT_STATUS_EQUAL(status, NT_STATUS_DOMAIN_CONTROLLER_NOT_FOUND)) {
+ return status;
+ }
+
+ /* Should we try again with site_name == NULL ? */
+ if ((site_name == NULL) || (site_name[0] == '\0')) {
+ status = dsgetdcname_internal(mem_ctx,
+ msg_ctx,
+ domain_name,
+ domain_guid,
+ NULL,
+ flags,
+ info);
+ }
return status;
}