diff --git a/lib/Net/LDAP3.php b/lib/Net/LDAP3.php
index eccd8e523e8bbf6204a67cbe8b0fc34f06855ef0..fd5f24cb7ef716e222cbf39183a05b8b4fd2e913 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";