idmap_ad: Pass tldap debug messages on to DEBUG()
authorStefan Metzmacher <metze@samba.org>
Tue, 11 Aug 2020 16:24:39 +0000 (18:24 +0200)
committerVolker Lendecke <vl@samba.org>
Fri, 21 Aug 2020 19:14:33 +0000 (19:14 +0000)
Bug: https://bugzilla.samba.org/show_bug.cgi?id=14465

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Volker Lendecke <vl@samba.org>
source3/winbindd/idmap_ad.c

index 6d879cdf4d7b667746faa603e2922f0562d54774..3bfeeee2d74b0a5268be0f3a91014d457244a913 100644 (file)
@@ -254,6 +254,41 @@ static TLDAPRC get_posix_schema_names(struct tldap_context *ld,
        return TLDAP_SUCCESS;
 }
 
+static void idmap_ad_tldap_debug(void *log_private,
+                                enum tldap_debug_level level,
+                                const char *fmt,
+                                va_list ap)
+{
+       int samba_level = -1;
+
+       switch (level) {
+       case TLDAP_DEBUG_FATAL:
+               samba_level = DBGLVL_ERR;
+               break;
+       case TLDAP_DEBUG_ERROR:
+               samba_level = DBGLVL_ERR;
+               break;
+       case TLDAP_DEBUG_WARNING:
+               samba_level = DBGLVL_WARNING;
+               break;
+       case TLDAP_DEBUG_TRACE:
+               samba_level = DBGLVL_DEBUG;
+               break;
+       }
+
+       if (CHECK_DEBUGLVL(samba_level)) {
+               char *s = NULL;
+               int ret;
+
+               ret = vasprintf(&s, fmt, ap);
+               if (ret == -1) {
+                       return;
+               }
+               DEBUG(samba_level, ("idmap_ad_tldap: %s", s));
+               free(s);
+       }
+}
+
 static NTSTATUS idmap_ad_get_tldap_ctx(TALLOC_CTX *mem_ctx,
                                       const char *domname,
                                       struct tldap_context **pld)
@@ -307,6 +342,7 @@ static NTSTATUS idmap_ad_get_tldap_ctx(TALLOC_CTX *mem_ctx,
                TALLOC_FREE(dcinfo);
                return NT_STATUS_NO_MEMORY;
        }
+       tldap_set_debug(ld, idmap_ad_tldap_debug, NULL);
 
        /*
         * Here we use or own machine account as