lib/api lib/kolab_utils.php

Aleksander Machniak machniak at kolabsys.com
Tue Jan 6 10:11:11 CET 2015


 lib/api/kolab_api_service_form_value.php |    7 +++----
 lib/kolab_utils.php                      |   12 ++++++------
 2 files changed, 9 insertions(+), 10 deletions(-)

New commits:
commit 21cc180730b3a82dbd2b758d9f785f8105dc8ace
Author: Aleksander Machniak <machniak at kolabsys.com>
Date:   Tue Jan 6 04:09:36 2015 -0500

    Fix regression in searching for user's OU in select_options_ou() (#4164)
    
    There was also a PHP warning: "array_map(): Argument #2 should be an array..."

diff --git a/lib/api/kolab_api_service_form_value.php b/lib/api/kolab_api_service_form_value.php
index 970f680..230cff6 100644
--- a/lib/api/kolab_api_service_form_value.php
+++ b/lib/api/kolab_api_service_form_value.php
@@ -1061,12 +1061,11 @@ class kolab_api_service_form_value extends kolab_api_service
         $base_dn = $auth->subject_base_dn($object_key, $object_type);
 
         if (!empty($postdata['id'])) {
-            $subjects = $auth->search($base_dn, '(' . $unique_attr . '=' . $postdata['id'] . ')');
+            $subjects = $auth->search($base_dn, '(' . $unique_attr . '=' . $postdata['id'] . ')', 'sub', array('dn'));
 
             if ($subjects) {
-                $subjects = $subjects->entries(true);
-                $subject = array_shift($subjects);
-                $subject_dn = key($subject);
+                $subjects              = $subjects->entries(true);
+                $subject_dn            = key($subjects);
                 $subject_dn_components = kolab_utils::explode_dn($subject_dn);
 
                 if ($subject_dn_components) {
diff --git a/lib/kolab_utils.php b/lib/kolab_utils.php
index 91dad55..822c2f4 100644
--- a/lib/kolab_utils.php
+++ b/lib/kolab_utils.php
@@ -171,16 +171,16 @@ class kolab_utils
      *
      * @param string $dn LDAP DN string
      *
-     * @return array Exploded DN (uses unicode encoding)
+     * @return array|bool Exploded DN (uses unicode encoding), False on failure
      */
     public static function explode_dn($dn)
     {
-        $result = ldap_explode_dn($dn, 0);
+        if ($result = ldap_explode_dn($dn, 0)) {
+            // get rid of count
+            unset($result['count']);
 
-        // get rid of count
-        unset($result['count']);
-
-        $result = array_map(array('kolab_utils', 'decode_dn'), $result);
+            $result = array_map(array('kolab_utils', 'decode_dn'), $result);
+        }
 
         return $result;
     }




More information about the commits mailing list