From: Volker Lendecke Date: Mon, 11 May 2026 19:23:56 +0000 (+0200) Subject: net ads dns: Use A/AAAA records if the NS query gave them X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f1d0e82cce4d22b78b1e34dcd6f311a15b8ecd55;p=thirdparty%2Fsamba.git net ads dns: Use A/AAAA records if the NS query gave them Windows tends to give us the addresses in the NS response, so try to avoid additional round-trips. As before, just use the first record we were given. Signed-off-by: Volker Lendecke Reviewed-by: Stefan Metzmacher --- diff --git a/source3/utils/net_ads_join_dns.c b/source3/utils/net_ads_join_dns.c index 9473ab23dd3..a6ea8b4b33e 100644 --- a/source3/utils/net_ads_join_dns.c +++ b/source3/utils/net_ads_join_dns.c @@ -50,7 +50,6 @@ static NTSTATUS net_update_dns_internal(struct net_context *c, size_t ns_count = 0, i; NTSTATUS status = NT_STATUS_UNSUCCESSFUL; DNS_ERROR dns_err; - fstring dns_server; const char *dnsdomain = NULL; char *root_domain = NULL; uint32_t ttl = 3600; @@ -155,6 +154,8 @@ static NTSTATUS net_update_dns_internal(struct net_context *c, do_update: for (i=0; i < ns_count; i++) { + struct dns_rr_ns *ns = &nameservers[i]; + struct ssaddr_buf addstrbuf; uint32_t flags = DNS_UPDATE_SIGNED | DNS_UPDATE_UNSIGNED | @@ -177,13 +178,20 @@ do_update: status = NT_STATUS_UNSUCCESSFUL; + if (talloc_array_length(ns->ss_s) == 0) { + /* + * ads_dns_lookup_ns gave no addresses even + * though it tries to find them if they did + * not come with the NS query reply + */ + continue; + } + /* Now perform the dns update - we'll try non-secure and if we fail, we'll follow it up with a secure update */ - fstrcpy( dns_server, nameservers[i].hostname ); - - dns_err = DoDNSUpdate(dns_server, - dns_server, + dns_err = DoDNSUpdate(ssaddr_str_buf(&ns->ss_s[0], &addstrbuf), + ns->hostname, dnsdomain, machine_name, creds,