summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJeroen van Meeuwen (Kolab Systems) <vanmeeuwen@kolabsys.com>2012-09-05 09:06:33 +0100
committerJeroen van Meeuwen (Kolab Systems) <vanmeeuwen@kolabsys.com>2012-09-05 09:06:33 +0100
commit83537043c792be58aec58eb548acedafb1f0eb98 (patch)
tree579340c846dd77e5547cdb28c31845695a2eb319
parente0ad3543b135342cbf15da350683cb3813aa8b0e (diff)
downloadwebadmin-83537043c792be58aec58eb548acedafb1f0eb98.tar.gz
Test for result values before using the results as if they were valid (#987)
-rw-r--r--lib/api/kolab_api_service_form_value.php22
1 files changed, 15 insertions, 7 deletions
diff --git a/lib/api/kolab_api_service_form_value.php b/lib/api/kolab_api_service_form_value.php
index d5eaf87..4936f30 100644
--- a/lib/api/kolab_api_service_form_value.php
+++ b/lib/api/kolab_api_service_form_value.php
@@ -781,13 +781,21 @@ class kolab_api_service_form_value extends kolab_api_service
if (!empty($postdata['id'])) {
$subjects = $auth->search($base_dn, '(' . $unique_attr . '=' . $postdata['id'] . ')')->entries(TRUE);
- $subject = array_shift($subjects);
- $subject_dn = key($subject);
- $subject_dn_components = ldap_explode_dn($subject_dn, 0);
- unset($subject_dn_components['count']);
- array_shift($subject_dn_components);
- $default = strtolower(implode(',', $subject_dn_components));
- } else {
+
+ if ($subjects) {
+ $subject = array_shift($subjects);
+ $subject_dn = key($subject);
+ $subject_dn_components = ldap_explode_dn($subject_dn, 0);
+
+ if ($subject_dn_components) {
+ unset($subject_dn_components['count']);
+ array_shift($subject_dn_components);
+ $default = strtolower(implode(',', $subject_dn_components));
+ }
+ }
+ }
+
+ if (empty($default)) {
$default = $base_dn;
}