1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33
|
From: William Desportes <williamdes@wdes.fr>
Date: Fri, 11 Apr 2025 14:27:35 +0200
Subject: Fix ldap_connect with two arguments is deprecated
Origin: vendor
Forwarded: https://github.com/leenooks/phpLDAPadmin/pull/309/files#diff-3043940ca83018fe979828ba1a135380bc5418e4f5a395a7b32fad548d30f4fb
---
lib/ds_ldap.php | 12 ++++++++----
1 file changed, 8 insertions(+), 4 deletions(-)
diff --git a/lib/ds_ldap.php b/lib/ds_ldap.php
index 11c527d..a307c08 100644
--- a/lib/ds_ldap.php
+++ b/lib/ds_ldap.php
@@ -204,10 +204,14 @@ class ldap extends DS {
if (function_exists('run_hook'))
run_hook('pre_connect',array('server_id'=>$this->index,'method'=>$method));
- if ($this->getValue('server','port'))
- $resource = ldap_connect($this->getValue('server','host'),$this->getValue('server','port'));
- else
- $resource = ldap_connect($this->getValue('server','host'));
+ $uri = $this->getValue('server','host');
+ if (strpos($uri, '://') === false) {
+ $uri = 'ldap://' . urlencode($uri);
+ if ($this->getValue('server','port')) {
+ $uri .= ':' . $this->getValue('server','port');
+ }
+ }
+ $resource = ldap_connect($uri);
$this->noconnect = false;
$CACHE[$this->index][$method] = $resource;
|