lib/Auth lib/ext

Aleksander Machniak machniak at kolabsys.com
Tue Sep 10 09:28:33 CEST 2013


 lib/Auth/LDAP.php     |    8 ++++----
 lib/ext/Net/LDAP3.php |   21 +++++++++++++++++----
 2 files changed, 21 insertions(+), 8 deletions(-)

New commits:
commit 49651423dbd22b1cdb736a6b84323a92f9548882
Author: Aleksander Machniak <alec at alec.pl>
Date:   Tue Sep 10 09:28:02 2013 +0200

    Fix unhandled ldap errors + some CS fixes (Bug #2201)

diff --git a/lib/Auth/LDAP.php b/lib/Auth/LDAP.php
index 989d58a..0434b45 100644
--- a/lib/Auth/LDAP.php
+++ b/lib/Auth/LDAP.php
@@ -1249,7 +1249,7 @@ class LDAP extends Net_LDAP3 {
             'attributeLevelRights' => array(),
         );
 
-        $subject    = $this->_search($subject_dn);
+        $subject = $this->_search($subject_dn);
 
         if (!$subject) {
             return $rights;
@@ -1386,7 +1386,7 @@ class LDAP extends Net_LDAP3 {
             $domain_name_attribute = 'associateddomain';
         }
 
-        $domain_filter         = "(&" . $domain_filter . "(" . $domain_name_attribute . "=" . $domain . "))";
+        $domain_filter = "(&" . $domain_filter . "(" . $domain_name_attribute . "=" . $domain . "))";
 
         $result = $this->_search($domain_base_dn, $domain_filter);
 
@@ -1394,8 +1394,8 @@ class LDAP extends Net_LDAP3 {
             return $this->_standard_root_dn($domain);
         }
 
-        $entries = $result->entries(true);
-        $entry_dn = key($entries);
+        $entries     = $result->entries(true);
+        $entry_dn    = key($entries);
         $entry_attrs = $entries[$entry_dn];
 
         if (is_array($entry_attrs)) {
diff --git a/lib/ext/Net/LDAP3.php b/lib/ext/Net/LDAP3.php
index 6451d09..6de153b 100644
--- a/lib/ext/Net/LDAP3.php
+++ b/lib/ext/Net/LDAP3.php
@@ -885,7 +885,7 @@ class Net_LDAP3
             ")");
 
         if ($entries) {
-            $groups  = array_keys($entries->entries(TRUE));
+            $groups = array_keys($entries->entries(TRUE));
         }
 
         return $groups;
@@ -993,7 +993,7 @@ class Net_LDAP3
             return $replica_hosts;
         }
 
-	$this->_debug("Replication agreements found: " . var_export($result->entries(TRUE), TRUE));
+        $this->_debug("Replication agreements found: " . var_export($result->entries(TRUE), TRUE));
 
         foreach ($result->entries(TRUE) as $dn => $attrs) {
             if (!in_array($attrs['nsds5replicahost'], $replica_hosts)) {
@@ -1171,6 +1171,10 @@ class Net_LDAP3
 
         $entry = $this->search($dn);
 
+        if (!$entry) {
+            return array();
+        }
+
         $this->_debug("ENTRIES for \$dn $dn", $entry);
 
         foreach ($entry[$dn] as $attribute => $value) {
@@ -1851,13 +1855,13 @@ class Net_LDAP3
             $this->find_vlv_indexes_and_searches(true);
         }
 
-        if (empty($this->_vlv_indexes_and_searches) && !is_array($this->_vlv_indexes_and_searches)) {
+        if (empty($this->_vlv_indexes_and_searches)) {
             return false;
         }
 
         $this->_debug("Existing vlv index and search information", $this->_vlv_indexes_and_searches);
 
-        if (array_key_exists($base_dn, $this->_vlv_indexes_and_searches) && !empty($this->_vlv_indexes_and_searches[$base_dn])) {
+        if (!empty($this->_vlv_indexes_and_searches[$base_dn])) {
             $this->_debug("Found a VLV for base_dn: " . $base_dn);
             if ($this->_vlv_indexes_and_searches[$base_dn]['filter'] == $filter) {
                 $this->_debug("Filter matches");
@@ -1928,6 +1932,11 @@ class Net_LDAP3
                 0
             );
 
+        if ($search_result === false) {
+            $this->_debug("Search for '(objectclass=vlvsearch)' on '$config_root_dn' failed:".ldap_error($this->conn));
+            return;
+        }
+
         $vlv_searches = new Net_LDAP3_Result($this->conn, $config_root_dn, '(objectclass=vlvsearch)', 'sub', $search_result);
 
         if ($vlv_searches->count() < 1) {
@@ -1956,6 +1965,10 @@ class Net_LDAP3
                     0
                 );
 
+            if ($index_result === false) {
+                $this->_debug("Search for '(objectclass=vlvindex)' on '$vlv_search_dn' failed:".ldap_error($this->conn));
+                continue;
+            }
 
             $vlv_indexes = new Net_LDAP3_Result($this->conn, $vlv_search_dn, '(objectclass=vlvindex)', 'sub', $index_result);
             $vlv_indexes = $vlv_indexes->entries(true);




More information about the commits mailing list