From: Guilhem Moulin <guilhem@debian.org>
Date: Sat, 11 Feb 2023 23:08:55 +0100
Subject: Port to php-ldap 8.1

In PHP 8.1 LDAP resources were migrated to LDAP\Connection, LDAP\Result,
and LDAP\ResultEntry objects, see https://php.watch/versions/8.1/LDAP-resource .

This breaks compatibility with php-ldap <8.1.
---
 Net/LDAP2.php | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/Net/LDAP2.php b/Net/LDAP2.php
index aaa7f49..0b26a0c 100644
--- a/Net/LDAP2.php
+++ b/Net/LDAP2.php
@@ -698,7 +698,9 @@ class Net_LDAP2 extends PEAR
     */
     public function _Net_LDAP2()
     {
-        @ldap_close($this->_link);
+        if ($this->_link !== false) {
+            @ldap_close($this->_link);
+        }
     }
 
     /**
