From ed206ea0bfd654d1464c55e63678f54ea491629e Mon Sep 17 00:00:00 2001 From: Kirill Roskolii Date: Wed, 17 Apr 2024 09:34:57 +1200 Subject: [PATCH 1/3] Document how to debug connection issues --- reference/ldap/functions/ldap-set-option.xml | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/reference/ldap/functions/ldap-set-option.xml b/reference/ldap/functions/ldap-set-option.xml index 26157bbd2666..babda6211680 100644 --- a/reference/ldap/functions/ldap-set-option.xml +++ b/reference/ldap/functions/ldap-set-option.xml @@ -307,6 +307,23 @@ if (!ldap_set_option($ds, LDAP_OPT_SERVER_CONTROLS, array($ctrl1, $ctrl2))) { echo "Failed to set server controls"; } ?> +]]> + + + + Debugging connection issue + + ]]> From 763a51c99e2713bcffb94ea5ea1f9f4190356911 Mon Sep 17 00:00:00 2001 From: lacatoire Date: Fri, 25 Sep 2026 17:00:35 +0200 Subject: [PATCH 2/3] ldap: document the LDAP_OPT_DEBUG_LEVEL levels and fix the debugging example The example had a TODO, used undefined variables and said the option is ignored when set after ldap_connect(). ldap_connect() does not connect yet: set later, the option still traces the operations that follow, and set before it also traces the initialization. List the OpenLDAP levels in the constant description (PHP has no constants for them) and say that the traces go to stderr. --- reference/ldap/constants.xml | 78 +++++++++++++++++++- reference/ldap/functions/ldap-set-option.xml | 19 ++--- 2 files changed, 86 insertions(+), 11 deletions(-) diff --git a/reference/ldap/constants.xml b/reference/ldap/constants.xml index 31a0cc52e660..8f9c2d336d6b 100644 --- a/reference/ldap/constants.xml +++ b/reference/ldap/constants.xml @@ -226,8 +226,82 @@ - Specifies a bitwise level for debug traces. - + Specifies a bitwise level for debug traces. The traces are written to + stderr. The levels are those defined by OpenLDAP in + ldap_log.h, which PHP does not expose as constants: + + + + + 1: LDAP_DEBUG_TRACE + + + + + 2: LDAP_DEBUG_PACKETS + + + + + 4: LDAP_DEBUG_ARGS + + + + + 8: LDAP_DEBUG_CONNS + + + + + 16: LDAP_DEBUG_BER + + + + + 32: LDAP_DEBUG_FILTER + + + + + 64: LDAP_DEBUG_CONFIG + + + + + 128: LDAP_DEBUG_ACL + + + + + 256: LDAP_DEBUG_STATS + + + + + 512: LDAP_DEBUG_STATS2 + + + + + 1024: LDAP_DEBUG_SHELL + + + + + 2048: LDAP_DEBUG_PARSE + + + + + 16384: LDAP_DEBUG_SYNC + + + + + -1: LDAP_DEBUG_ANY + + + diff --git a/reference/ldap/functions/ldap-set-option.xml b/reference/ldap/functions/ldap-set-option.xml index babda6211680..6e7e73135056 100644 --- a/reference/ldap/functions/ldap-set-option.xml +++ b/reference/ldap/functions/ldap-set-option.xml @@ -311,18 +311,19 @@ if (!ldap_set_option($ds, LDAP_OPT_SERVER_CONTROLS, array($ctrl1, $ctrl2))) { - Debugging connection issue + Debugging a connection issue ]]> From ae0af6cc97c1342151a818b2ef6c0d2fe4f89a33 Mon Sep 17 00:00:00 2001 From: lacatoire Date: Fri, 25 Sep 2026 17:08:38 +0200 Subject: [PATCH 3/3] ldap: do not list the OpenLDAP debug levels The levels are defined by OpenLDAP, not by PHP, which has no constants for them. Say where they come from instead of copying the table. --- reference/ldap/constants.xml | 79 +------------------- reference/ldap/functions/ldap-set-option.xml | 2 +- 2 files changed, 5 insertions(+), 76 deletions(-) diff --git a/reference/ldap/constants.xml b/reference/ldap/constants.xml index 8f9c2d336d6b..525c808093b6 100644 --- a/reference/ldap/constants.xml +++ b/reference/ldap/constants.xml @@ -227,81 +227,10 @@ Specifies a bitwise level for debug traces. The traces are written to - stderr. The levels are those defined by OpenLDAP in - ldap_log.h, which PHP does not expose as constants: - - - - - 1: LDAP_DEBUG_TRACE - - - - - 2: LDAP_DEBUG_PACKETS - - - - - 4: LDAP_DEBUG_ARGS - - - - - 8: LDAP_DEBUG_CONNS - - - - - 16: LDAP_DEBUG_BER - - - - - 32: LDAP_DEBUG_FILTER - - - - - 64: LDAP_DEBUG_CONFIG - - - - - 128: LDAP_DEBUG_ACL - - - - - 256: LDAP_DEBUG_STATS - - - - - 512: LDAP_DEBUG_STATS2 - - - - - 1024: LDAP_DEBUG_SHELL - - - - - 2048: LDAP_DEBUG_PARSE - - - - - 16384: LDAP_DEBUG_SYNC - - - - - -1: LDAP_DEBUG_ANY - - - + stderr. The levels are defined by OpenLDAP, in its + ldap_log.h header; PHP does not expose them as + constants. + diff --git a/reference/ldap/functions/ldap-set-option.xml b/reference/ldap/functions/ldap-set-option.xml index 6e7e73135056..3a687f2a07cb 100644 --- a/reference/ldap/functions/ldap-set-option.xml +++ b/reference/ldap/functions/ldap-set-option.xml @@ -318,7 +318,7 @@ if (!ldap_set_option($ds, LDAP_OPT_SERVER_CONTROLS, array($ctrl1, $ctrl2))) { // A NULL connection sets the option for the whole process (OpenLDAP only). // Set before ldap_connect(), it also traces the initialization; set later, // only the operations that follow are traced. -// 7 = LDAP_DEBUG_TRACE (1) | LDAP_DEBUG_PACKETS (2) | LDAP_DEBUG_ARGS (4). +// 7 combines the OpenLDAP levels 1 (trace), 2 (packets) and 4 (arguments). // The traces are written to stderr, not to the output of the script. ldap_set_option(null, LDAP_OPT_DEBUG_LEVEL, 7);