]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
s3:libads: Reset ads->config.flags in ads_disconnect()
authorPavel Filipenský <pfilipensky@samba.org>
Mon, 19 Jan 2026 13:33:52 +0000 (14:33 +0100)
committerPavel Filipensky <pfilipensky@samba.org>
Thu, 22 Jan 2026 08:11:34 +0000 (08:11 +0000)
This is doing the same thing in ads_disconnect() as commit
a26f535 Clear previous CLDAP ping flags when reusing the ADS_STRUCT
did in ads_current_time()

In this case we:

1) found cached ADS_STRUCT which already has ads->config.flags set:

  lookup_groupmem()
    ads_cached_connection()
      ads_cached_connection_reuse()

2) started search which immediately timeouts (the cached conn. was dead)

  ads_do_search_retry_internal()
    ldap_search_with_timeout() - IO_TIMEOUT

3) Retry loop finds a new DC and tries to connect

  ads_do_search_retry_internal()
    ads_disconnect()
    ads_find_dc()
    ads_try_connect()
      netlogon_pings()
        check_cldap_reply_required_flags()

4) check_cldap_reply_required_flags() fails since ads->config.flags
   (stored possibly long time ago) contain:

   NBT_SERVER_CLOSEST  0x00000080
     which is misinterpreted as:
   DS_PDC_REQUIRED     0x00000080

   the newly found DC is not PDC (we asked for DS_ONLY_LDAP_NEEDED)
   and since previous DC had NBT_SERVER_CLOSEST we want DS_PDC_REQUIRED
   and fail.

We should anyway avoid mixing independent namespaces  NBT_* and DS_*
in the same flag.
Next commit will do that.

BUG: https://bugzilla.samba.org/show_bug.cgi?id=15972

Signed-off-by: Pavel Filipenský <pfilipensky@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
source3/libads/ldap.c

index e3e4ff2b240c14e31e4b09dec5d7309f1a41ec21..92397213bdb42a11a028cc90adb80ba4fe526412 100644 (file)
@@ -1265,6 +1265,7 @@ void ads_disconnect(ADS_STRUCT *ads)
        if (ads->ldap_wrap_data.mem_ctx) {
                talloc_free(ads->ldap_wrap_data.mem_ctx);
        }
+       ads->config.flags = 0;
        ads_zero_ldap(ads);
        ZERO_STRUCT(ads->ldap_tls_data);
        ZERO_STRUCT(ads->ldap_wrap_data);