From 9b6e0bab0004070575e4c653df295581cc51afad Mon Sep 17 00:00:00 2001 From: "yann.droniou" Date: Tue, 21 Feb 2023 14:26:29 +0100 Subject: [PATCH 1/2] Fix LDAP Authentification failure with error 500 --- htdocs/core/class/ldap.class.php | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/htdocs/core/class/ldap.class.php b/htdocs/core/class/ldap.class.php index b2b5e2c6e93..38220f7a17b 100644 --- a/htdocs/core/class/ldap.class.php +++ b/htdocs/core/class/ldap.class.php @@ -344,12 +344,7 @@ class Ldap */ public function close() { - $r_type = get_resource_type($this->connection); - if ($this->connection && ($r_type === "Unknown" || !@ldap_close($this->connection))) { - return false; - } else { - return true; - } + return $this->unbind(); } /** @@ -401,7 +396,7 @@ class Ldap public function unbind() { $this->result = true; - if ($this->connection) { + if (is_resource($this->connection)) { $this->result = @ldap_unbind($this->connection); } if ($this->result) { From 1b64068fc8ea36b8ab0fc7784ced61a7c491b656 Mon Sep 17 00:00:00 2001 From: "yann.droniou" Date: Thu, 2 Mar 2023 16:20:32 +0100 Subject: [PATCH 2/2] Fix PR for ldap is_ressource or is_object in unbind() --- htdocs/core/class/ldap.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/class/ldap.class.php b/htdocs/core/class/ldap.class.php index 38220f7a17b..1d6e51c633d 100644 --- a/htdocs/core/class/ldap.class.php +++ b/htdocs/core/class/ldap.class.php @@ -396,7 +396,7 @@ class Ldap public function unbind() { $this->result = true; - if (is_resource($this->connection)) { + if (is_resource($this->connection) || is_object($this->connection)) { $this->result = @ldap_unbind($this->connection); } if ($this->result) {