From 9124ca2c2ccd3e60bdd8a98ab99e33b1efb0beb6 Mon Sep 17 00:00:00 2001 From: Thibault Dockx <thibault.dockx@fusiondirectory.org> Date: Mon, 10 Mar 2025 16:26:02 +0000 Subject: [PATCH] :ambulance: (setup) - fixes ldap p2 backup and some fixes in ldap. --- include/class_ldap.inc | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/include/class_ldap.inc b/include/class_ldap.inc index f1bc05ec5..b6b74c276 100755 --- a/include/class_ldap.inc +++ b/include/class_ldap.inc @@ -604,10 +604,17 @@ class LDAP * * \param $srp srp */ - function count ($srp) + function count($srp) { if ($this->hascon) { - if ($this->hasres[$srp] && !is_bool($this->hasres[$srp])) { + if (!empty($this->hasres[$srp])) { + // Ensure $this->sr[$srp] is a valid LDAP result + if ($this->sr[$srp] === false) { + $this->error = "LDAP search returned no results"; + logging::debug(DEBUG_LDAP, __LINE__, __FUNCTION__, __FILE__, $this->error, 'count()'); + return 0; // Return 0 as there are no entries + } + $rv = @ldap_count_entries($this->cid, $this->sr[$srp]); $this->error = @ldap_error($this->cid); logging::debug(DEBUG_LDAP, __LINE__, __FUNCTION__, __FILE__, $this->error, 'count()'); @@ -624,7 +631,6 @@ class LDAP } } - /*! * \brief Remove * -- GitLab