From befe294986668e54c2e0b32a990e51cfc13a47af Mon Sep 17 00:00:00 2001 From: Lenaick Date: Mon, 27 Apr 2026 14:26:38 +0200 Subject: [PATCH] =?UTF-8?q?N=C2=B03472=20-=20Refactor=20LDAP=20debug=20lev?= =?UTF-8?q?el=20handling=20to=20ensure=20proper=20logging=20during=20conne?= =?UTF-8?q?ction=20attempts=20(#892)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../2.x/authent-ldap/datamodel.authent-ldap.xml | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/datamodels/2.x/authent-ldap/datamodel.authent-ldap.xml b/datamodels/2.x/authent-ldap/datamodel.authent-ldap.xml index 54bb30ea84..2d60a7030e 100644 --- a/datamodels/2.x/authent-ldap/datamodel.authent-ldap.xml +++ b/datamodels/2.x/authent-ldap/datamodel.authent-ldap.xml @@ -97,18 +97,19 @@ $bDebug = isset($aServerParams['debug']) ? $aServerParams['debug'] : false; } + if (array_key_exists(LDAP_OPT_DEBUG_LEVEL, $aOptions)) + { + // Set debug level before trying to connect, so that debug info appear in the PHP error log if ldap_connect goes wrong + $bRet = ldap_set_option(null, LDAP_OPT_DEBUG_LEVEL, $aOptions[LDAP_OPT_DEBUG_LEVEL]); + $this->LogInfo($bDebug, "ldap_set_option('LDAP_OPT_DEBUG_LEVEL', '{$aOptions[LDAP_OPT_DEBUG_LEVEL]}') returned ".($bRet ? 'true' : 'false')); + } + $hDS = @ldap_connect($sURI); if ($hDS === false) { $this->LogIssue($bDebug, "ldap_authentication: can not connect to the LDAP server '$sURI'. Check the configuration file config-itop.php."); return false; } - if (array_key_exists(LDAP_OPT_DEBUG_LEVEL, $aOptions)) - { - // Set debug level before trying to connect, so that debug info appear in the PHP error log if ldap_connect goes wrong - $bRet = ldap_set_option($hDS, LDAP_OPT_DEBUG_LEVEL, $aOptions[LDAP_OPT_DEBUG_LEVEL]); - $this->LogInfo($bDebug, "ldap_set_option('LDAP_OPT_DEBUG_LEVEL', '{$aOptions[LDAP_OPT_DEBUG_LEVEL]}') returned ".($bRet ? 'true' : 'false')); - } foreach($aOptions as $name => $value) { $bRet = ldap_set_option($hDS, $name, $value);