From 56fc50b0aa91cccbb356ab82c695e8dfa9788f9f Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Thu, 26 Sep 2024 19:14:40 +0200 Subject: [PATCH] s3:libsmb: ads_dc_name() doesn't need to retry if we found a DC in the closest site Signed-off-by: Stefan Metzmacher Reviewed-by: Andreas Schneider --- source3/libsmb/namequery_dc.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/source3/libsmb/namequery_dc.c b/source3/libsmb/namequery_dc.c index c61d14e25e1..3a2f22129b8 100644 --- a/source3/libsmb/namequery_dc.c +++ b/source3/libsmb/namequery_dc.c @@ -60,7 +60,7 @@ static bool ads_dc_name(const char *domain, TALLOC_CTX *tmp_ctx = talloc_stackframe(); bool ok = false; ADS_STRUCT *ads; - char *sitename; + const char *sitename; int i; char addr[INET6_ADDRSTRLEN]; @@ -94,6 +94,11 @@ static bool ads_dc_name(const char *domain, has changed. If so, we need to re-do the DNS query to ensure we only find servers in our site. */ +#ifdef HAVE_ADS + if (ads_closest_dc(ads)) { + sitename = ads->config.client_site_name; + } else +#endif if (stored_sitename_changed(realm, sitename)) { sitename = sitename_fetch(tmp_ctx, realm); TALLOC_FREE(ads);