/src/samba/source3/lib/ldap_debug_handler.c
Line | Count | Source |
1 | | /* |
2 | | * Unix SMB/CIFS implementation. |
3 | | * Intercept libldap debug output. |
4 | | * Copyright (C) Michael Adam 2008 |
5 | | * |
6 | | * This program is free software; you can redistribute it and/or modify it |
7 | | * under the terms of the GNU General Public License as published by the Free |
8 | | * Software Foundation; either version 3 of the License, or (at your option) |
9 | | * any later version. |
10 | | * |
11 | | * This program is distributed in the hope that it will be useful, but WITHOUT |
12 | | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
13 | | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for |
14 | | * more details. |
15 | | * |
16 | | * You should have received a copy of the GNU General Public License along with |
17 | | * this program; if not, see <http://www.gnu.org/licenses/>. |
18 | | */ |
19 | | |
20 | | #include "includes.h" |
21 | | #include "smb_ldap.h" |
22 | | |
23 | | #if defined(HAVE_LDAP) && defined(HAVE_LBER_LOG_PRINT_FN) |
24 | | static void samba_ldap_log_print_fn(LDAP_CONST char *data) |
25 | 0 | { |
26 | 0 | DEBUG(lp_ldap_debug_threshold(), ("[LDAP] %s", data)); |
27 | 0 | } |
28 | | #endif |
29 | | |
30 | | void init_ldap_debugging(void) |
31 | 0 | { |
32 | 0 | #if defined(HAVE_LDAP) && defined(HAVE_LBER_LOG_PRINT_FN) |
33 | 0 | int ret; |
34 | 0 | int ldap_debug_level = lp_ldap_debug_level(); |
35 | |
|
36 | 0 | ret = ldap_set_option(NULL, LDAP_OPT_DEBUG_LEVEL, &ldap_debug_level); |
37 | 0 | if (ret != LDAP_OPT_SUCCESS) { |
38 | 0 | DEBUG(10, ("Error setting LDAP debug level.\n")); |
39 | 0 | } |
40 | |
|
41 | 0 | if (ldap_debug_level == 0) { |
42 | 0 | return; |
43 | 0 | } |
44 | | |
45 | 0 | ret = ber_set_option(NULL, LBER_OPT_LOG_PRINT_FN, |
46 | 0 | (void *)samba_ldap_log_print_fn); |
47 | 0 | if (ret != LBER_OPT_SUCCESS) { |
48 | | DEBUG(10, ("Error setting LBER log print function.\n")); |
49 | 0 | } |
50 | 0 | #endif /* HAVE_LDAP && HAVE_LBER_LOG_PRINT_FN */ |
51 | 0 | } |