From a2455eeb46336176f472c4e8f442b3f834753786 Mon Sep 17 00:00:00 2001
From: Christian Mollekopf <mollekopf@apheleia-it.ch>
Date: Wed, 26 Apr 2023 18:45:33 +0200
Subject: [PATCH] Support for ldapsearch 2.4

Summary:
as provided by:
openldap-clients-2.4.46-18.el8.x86_64

Differential Revision: https://git.kolab.org/D4283
---
 lib/Net/LDAP3.php | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/lib/Net/LDAP3.php b/lib/Net/LDAP3.php
index eccd8e5..fd5f24c 100644
--- a/lib/Net/LDAP3.php
+++ b/lib/Net/LDAP3.php
@@ -772,6 +772,9 @@ class Net_LDAP3
         if (!is_file($moz_ldapsearch)) {
             $moz_ldapsearch = "/usr/lib/mozldap/ldapsearch";
         }
+        if (!is_file($moz_ldapsearch)) {
+            $moz_ldapsearch = "/usr/bin/ldapsearch";
+        }
         if (!is_file($moz_ldapsearch)) {
             $moz_ldapsearch = null;
         }
@@ -805,6 +808,10 @@ class Net_LDAP3
             $command[] = escapeshellarg(self::CONTROL_EFFECTIVE_RIGHTS . ':true');
             $command[] = "-c";
             $command[] = escapeshellarg('dn:' . $this->_current_bind_dn);
+        } else if ($moz_ldapsearch == "/usr/bin/ldapsearch") {
+            // Modern 389 DS:
+            $command[] = "-E";
+            $command[] = escapeshellarg("!" . self::CONTROL_EFFECTIVE_RIGHTS . '=:dn:' . $this->_current_bind_dn);
         } else {
             // For 389 DS:
             $command[] = "-J";
-- 
GitLab