diff --git a/application/libraries/Zend/Ldap.php b/application/libraries/Zend/Ldap.php index 41170af06..f1c3371ab 100644 --- a/application/libraries/Zend/Ldap.php +++ b/application/libraries/Zend/Ldap.php @@ -748,20 +748,17 @@ public function connect($host = null, $port = null, $useSsl = null, $useStartTls throw new Zend_Ldap_Exception(null, 'A host parameter is required'); } - $useUri = false; /* Because ldap_connect doesn't really try to connect, any connect error * will actually occur during the ldap_bind call. Therefore, we save the * connect string here for reporting it in error handling in bind(). */ $hosts = array(); - if (preg_match_all('~ldap(?:i|s)?://~', $host, $hosts, PREG_SET_ORDER) > 0) { + if (preg_match_all('~ldap(i|s)?://~', $host, $hosts, PREG_SET_ORDER) > 0) { $this->_connectString = $host; - $useUri = true; - $useSsl = false; + $useSsl = isset($hosts[0][1]) && $hosts[0][1] === 's' ? true : false; } else { if ($useSsl) { $this->_connectString = 'ldaps://' . $host; - $useUri = true; } else { $this->_connectString = 'ldap://' . $host; } @@ -772,10 +769,8 @@ public function connect($host = null, $port = null, $useSsl = null, $useStartTls $this->disconnect(); - /* Only OpenLDAP 2.2 + supports URLs so if SSL is not requested, just - * use the old form. - */ - $resource = ($useUri) ? @ldap_connect($this->_connectString) : @ldap_connect($host, $port); + /* PHP 8.3 change: multiarg ldap_connect is deprecated so use the string always */ + $resource = @ldap_connect($this->_connectString); if ($resource) { $this->_resource = $resource;