From 5a319cf437d75aad564ce7fd076cc5423722868b Mon Sep 17 00:00:00 2001 From: Aleksander Machniak <machniak@kolabsys.com> Date: Wed, 7 Jun 2023 10:32:15 +0200 Subject: [PATCH] Fix schema cache path for ldapi:// case --- lib/Net/LDAP3.php | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/lib/Net/LDAP3.php b/lib/Net/LDAP3.php index 7461be9..a4e3bca 100644 --- a/lib/Net/LDAP3.php +++ b/lib/Net/LDAP3.php @@ -2234,7 +2234,8 @@ class Net_LDAP3 $tls = $this->config_get('use_tls', false); foreach ((array) $this->config_get('hosts') as $host) { - $this->_debug("C: Connect [$host:$port]"); + $ldap_uri = $this->_host2uri($host, $port); + $this->_debug("C: Connect [{$ldap_uri}]"); $_ldap_cfg = [ 'host' => $host, @@ -2247,8 +2248,11 @@ class Net_LDAP3 $_ldap_schema_cache_cfg = [ 'max_age' => 86400, - 'path' => sprintf('%s/%s-Net_LDAP2_Schema.cache', - sys_get_temp_dir() ?: '/tmp', str_replace('://', ':', $host) . (strpos($host, ":$port") ? '' : ":$port")), + 'path' => sprintf( + '%s/%s-Net_LDAP2_Schema.cache', + sys_get_temp_dir() ?: '/tmp', + str_replace(['://', '/'], ':', $ldap_uri) + ), ]; $_ldap = Net_LDAP2::connect($_ldap_cfg); -- GitLab