From df35c04f46fb7b0d9cb8d3899ef8f39c2ecad81f Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Tue, 11 Aug 2020 18:24:39 +0200 Subject: [PATCH] idmap_ad: Pass tldap debug messages on to DEBUG() Bug: https://bugzilla.samba.org/show_bug.cgi?id=14465 Signed-off-by: Stefan Metzmacher Reviewed-by: Volker Lendecke (cherry picked from commit 7af2df01dff62d6d9ca572f320ef60dea41d6064) --- source3/winbindd/idmap_ad.c | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/source3/winbindd/idmap_ad.c b/source3/winbindd/idmap_ad.c index 6d879cdf4d7..3bfeeee2d74 100644 --- a/source3/winbindd/idmap_ad.c +++ b/source3/winbindd/idmap_ad.c @@ -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 -- 2.47.2