File: Fix-ldap_connect-2-params-deprecated.patch

package info (click to toggle)
phpldapadmin 1.2.6.7-4
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 5,528 kB
  • sloc: php: 17,684; javascript: 5,299; xml: 1,498; sh: 379; python: 148; makefile: 23
file content (33 lines) | stat: -rw-r--r-- 1,223 bytes parent folder | download
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;