summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAleksander Machniak <machniak@kolabsys.com>2015-01-06 09:09:36 (GMT)
committerAleksander Machniak <machniak@kolabsys.com>2015-01-06 09:09:36 (GMT)
commit21cc180730b3a82dbd2b758d9f785f8105dc8ace (patch)
tree972ff083b2b89182a3cb604eeb016ce1d6d983bc
parent9f5c1783654268d573888ab99578324d137871b0 (diff)
downloadkolab-wap-21cc180730b3a82dbd2b758d9f785f8105dc8ace.tar.gz
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..."
-rw-r--r--lib/api/kolab_api_service_form_value.php7
-rw-r--r--lib/kolab_utils.php12
2 files changed, 9 insertions, 10 deletions
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;
}