From: Pavel Filipenský Date: Mon, 19 Jan 2026 13:33:52 +0000 (+0100) Subject: s3:libads: Reset ads->config.flags in ads_disconnect() X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=9f3a35991feb01a8d2c2b69fa0b914bbc637a809;p=thirdparty%2Fsamba.git s3:libads: Reset ads->config.flags in ads_disconnect() 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ý Reviewed-by: Andreas Schneider --- diff --git a/source3/libads/ldap.c b/source3/libads/ldap.c index e3e4ff2b240..92397213bdb 100644 --- a/source3/libads/ldap.c +++ b/source3/libads/ldap.c @@ -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);