]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
lib/ldb-samba: allow ldb_get_opaque(ldb, "backend_no_debug_connect")
authorStefan Metzmacher <metze@samba.org>
Thu, 6 Mar 2025 16:23:39 +0000 (17:23 +0100)
committerRalph Boehme <slow@samba.org>
Thu, 3 Apr 2025 09:36:31 +0000 (09:36 +0000)
We don't want expected connect/bind failures in the log output...

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
lib/ldb-samba/ldb_ildap.c

index 0c051f143a7fc964f48bb7d4660418b434b4befd..8ddb0ae9b8d725356423cfb6fe9399a17e89cf2a 100644 (file)
@@ -916,6 +916,12 @@ static int ildb_connect(struct ldb_context *ldb, const char *url,
        NTSTATUS status = NT_STATUS_UNSUCCESSFUL;
        struct cli_credentials *creds;
        struct loadparm_context *lp_ctx;
+       const char *no_debug_str = ldb_get_opaque(ldb, "backend_no_debug_connect");
+       bool no_debug = false;
+
+       if (no_debug_str != NULL && no_debug_str[0] == '1') {
+               no_debug = true;
+       }
 
        lp_ctx = talloc_get_type(ldb_get_opaque(ldb, "loadparm"),
                                 struct loadparm_context);
@@ -948,6 +954,10 @@ static int ildb_connect(struct ldb_context *ldb, const char *url,
 
        status = ldap_connect(ildb->ldap, url);
        if (!NT_STATUS_IS_OK(status)) {
+               if (no_debug) {
+                       goto failed;
+               }
+
                ldb_debug(ldb, LDB_DEBUG_ERROR, "Failed to connect to ldap URL '%s' - %s",
                          url, ldap_errstr(ildb->ldap, module, status));
                goto failed;
@@ -970,6 +980,10 @@ static int ildb_connect(struct ldb_context *ldb, const char *url,
                        const char *password = cli_credentials_get_password(creds);
                        status = ldap_bind_simple(ildb->ldap, bind_dn, password);
                        if (!NT_STATUS_IS_OK(status)) {
+                               if (no_debug) {
+                                       goto failed;
+                               }
+
                                ldb_debug(ldb, LDB_DEBUG_ERROR, "Failed to bind - %s",
                                          ldap_errstr(ildb->ldap, module, status));
                                goto failed;
@@ -977,6 +991,10 @@ static int ildb_connect(struct ldb_context *ldb, const char *url,
                } else {
                        status = ldap_bind_sasl(ildb->ldap, creds, lp_ctx);
                        if (!NT_STATUS_IS_OK(status)) {
+                               if (no_debug) {
+                                       goto failed;
+                               }
+
                                ldb_debug(ldb, LDB_DEBUG_ERROR, "Failed to bind - %s",
                                          ldap_errstr(ildb->ldap, module, status));
                                goto failed;