lib/Auth

Aleksander Machniak machniak at kolabsys.com
Mon Nov 3 13:39:37 CET 2014


 lib/Auth/LDAP.php |   26 +++++++++++++++++---------
 1 file changed, 17 insertions(+), 9 deletions(-)

New commits:
commit be7ef6f18d07aa3f71be0184c8845c646fa09a18
Author: Aleksander Machniak <machniak at kolabsys.com>
Date:   Mon Nov 3 07:36:18 2014 -0500

    Fix _find_domain() optimization from commit 7bc79c68dd

diff --git a/lib/Auth/LDAP.php b/lib/Auth/LDAP.php
index cf5c062..a175fc8 100644
--- a/lib/Auth/LDAP.php
+++ b/lib/Auth/LDAP.php
@@ -1488,15 +1488,23 @@ class LDAP extends Net_LDAP3 {
         // use memcache
         $domain_dn = $this->get_cache_data($ckey);
 
-        // connect and bind only if needed
-        if (empty($this->_current_bind_dn)
-            && (!$domain_dn || empty($_SESSION['user']) || empty($_SESSION['user']->user_bind_dn))
-        ) {
-            $bind_dn = $this->conf->get('service_bind_dn');
-            $bind_pw = $this->conf->get('service_bind_pw');
-
-            if (!$this->bind($bind_dn, $bind_pw)) {
-                return false;
+        // connect and bind only if needed...
+        if (empty($this->_current_bind_dn)) {
+            $bind_dn = $_SESSION['user'] ? $_SESSION['user']->user_bind_dn : null;
+
+            // ...and it is needed if we ned to call _read() or _search() below
+            if (!$domain_dn || !$bind_dn) {
+                if ($bind_dn) {
+                    $bind_pw = $_SESSION['user']->user_bind_pw;
+                }
+                else {
+                    $bind_dn = $this->conf->get('service_bind_dn');
+                    $bind_pw = $this->conf->get('service_bind_pw');
+                }
+
+                if (!$this->bind($bind_dn, $bind_pw)) {
+                    return false;
+                }
             }
         }
 




More information about the commits mailing list