sq cldap_ping_list check_negative_conn_cache
authorStefan Metzmacher <metze@samba.org>
Thu, 17 Feb 2022 13:12:23 +0000 (14:12 +0100)
committerStefan Metzmacher <metze@samba.org>
Mon, 16 Oct 2023 08:23:19 +0000 (10:23 +0200)
source3/libads/ldap.c

index fe904e49a8bad9d4bd5b710061a9024bce336784..2c52205ff1c87e40969c4cbc4f03a4eae3febb9d 100644 (file)
@@ -405,20 +405,24 @@ static NTSTATUS cldap_ping_list(ADS_STRUCT *ads,
                /* Returns ok only if it matches the correct server type */
                ok = ads_try_connect(ads, false, &sa_list[i].u.ss);
 
-               if (ok) {
+               if (ok && ads->config.ldap_server_name) {
                        NTSTATUS status;
 
                        status = check_negative_conn_cache(domain,
                                        ads->config.ldap_server_name);
-                       if (NT_STATUS_IS_OK(status)) {
+                       if (!NT_STATUS_IS_OK(status)) {
                                /*
-                                * only use the server if it's not black listed
-                                * by name
+                                * if the the server is black listed
+                                * by name, we avoid using it.
                                 */
-                               return NT_STATUS_OK;
+                               ok = false;
                        }
                }
 
+               if (ok) {
+                       return NT_STATUS_OK;
+               }
+
                /* keep track of failures */
                add_failed_connection_entry(domain, server,
                                            NT_STATUS_UNSUCCESSFUL);