lib/ext lib/kolab_api_service.php

Aleksander Machniak machniak at kolabsys.com
Tue Sep 17 20:01:35 CEST 2013


 lib/ext/Net/LDAP3.php     |    9 ++++++++-
 lib/kolab_api_service.php |    1 +
 2 files changed, 9 insertions(+), 1 deletion(-)

New commits:
commit e467788e6ee6b0f12ccd65dd0b419ebb18d80d60
Author: Aleksander Machniak <alec at alec.pl>
Date:   Tue Sep 17 19:47:09 2013 +0200

    Skip searching for nsuniqueid if searched value is too short to be a unique identifier (Bug #2216)

diff --git a/lib/ext/Net/LDAP3.php b/lib/ext/Net/LDAP3.php
index 6e0ccc6..533fd15 100644
--- a/lib/ext/Net/LDAP3.php
+++ b/lib/ext/Net/LDAP3.php
@@ -815,12 +815,19 @@ class Net_LDAP3
     {
         $this->_debug("entry_dn on subject $subject");
         $is_dn = ldap_explode_dn($subject, 1);
-        $this->_debug($is_dn ? "entry_dn is a dn" : "entry_dn is not a dn");
 
         if (is_array($is_dn) && array_key_exists("count", $is_dn) && $is_dn["count"] > 0) {
+            $this->_debug("$subject is a dn");
             return $subject;
         }
 
+        $this->_debug("$subject is not a dn");
+
+        if (strlen($subject) < 16) {
+            $this->_debug("$subject is too short to be a unique identifier");
+            return;
+        }
+
         $unique_attr = $this->config_get('unique_attribute', 'nsuniqueid');
 
         $this->_debug("Using unique_attribute " . var_export($unique_attr, TRUE) . " at " . __FILE__ . ":" . __LINE__);
diff --git a/lib/kolab_api_service.php b/lib/kolab_api_service.php
index a154f7d..5ba4109 100644
--- a/lib/kolab_api_service.php
+++ b/lib/kolab_api_service.php
@@ -504,6 +504,7 @@ abstract class kolab_api_service
                 $attrs = array_merge($attrs, $extra_attrs);
             }
         }
+
         // Replace unique attribute with 'id' key
         $attrs['id'] = $attrs[$unique_attr];
         unset($attrs[$unique_attr]);




More information about the commits mailing list