Since PHP 8.3 ldap_connect() takes a single URI argument. connectBind() concatenated host and port as "host:port", which is a malformed URI for a scheme-less host (localhost, 192.168.0.2) since the host is then parsed as the URI scheme, so the following bind returns false. It also appended ":port" to an already qualified ldaps:// URI. Prefix scheme-less hosts with ldap:// and leave ldap(s):// URIs untouched. Signed-off-by: Dolicraft <clement@pixodeo.com>
This commit is contained in:
parent
5c6e4f486d
commit
fe1386fa2d
1 changed files with 5 additions and 2 deletions
|
|
@ -358,7 +358,10 @@ class Ldap
|
|||
dol_syslog(get_class($this)."::connectBind serverPing true, we try ldap_connect to ".$host, LOG_DEBUG);
|
||||
}
|
||||
if (version_compare(PHP_VERSION, '8.3.0', '>=')) {
|
||||
$uri = $host.':'.$this->serverPort;
|
||||
// Since PHP 8.3, ldap_connect() expects a single URI argument. A scheme-less
|
||||
// host (ex: localhost, 192.168.0.2) must be turned into a valid ldap:// URI,
|
||||
// otherwise the host is parsed as the URI scheme and the later bind fails.
|
||||
$uri = preg_match('/^ldaps?:\/\//i', $host) ? $host : 'ldap://'.$host.':'.$this->serverPort;
|
||||
$this->connection = ldap_connect($uri);
|
||||
} else {
|
||||
$this->connection = ldap_connect($host, $this->serverPort);
|
||||
|
|
@ -371,7 +374,7 @@ class Ldap
|
|||
dol_syslog(get_class($this)."::connectBind serverPing false, we try ldap_connect to ".$host, LOG_DEBUG);
|
||||
}
|
||||
if (version_compare(PHP_VERSION, '8.3.0', '>=')) {
|
||||
$uri = $host.':'.$this->serverPort;
|
||||
$uri = preg_match('/^ldaps?:\/\//i', $host) ? $host : 'ldap://'.$host.':'.$this->serverPort;
|
||||
$this->connection = ldap_connect($uri);
|
||||
} else {
|
||||
$this->connection = ldap_connect($host, $this->serverPort);
|
||||
|
|
|
|||
Loading…
Reference in a new issue