summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAleksander Machniak <alec@alec.pl>2012-10-25 10:24:01 (GMT)
committerJeroen van Meeuwen (Kolab Systems) <vanmeeuwen@kolabsys.com>2012-11-26 13:29:47 (GMT)
commitaac84b95b7a8c8aaeb8fe23ad7df69e65666db90 (patch)
treee39d1ba818123faa14525bf5d22f7a8b0a6cb7a7
parent3904a4c512c0fd1ab408910e8bdcfe9743e39f42 (diff)
downloadkolab-wap-aac84b95b7a8c8aaeb8fe23ad7df69e65666db90.tar.gz
Fix possible error in get_entry_attributes(s) where search() result
wasn't checked for error
-rw-r--r--lib/ext/Net/LDAP3.php15
1 files changed, 9 insertions, 6 deletions
diff --git a/lib/ext/Net/LDAP3.php b/lib/ext/Net/LDAP3.php
index 2980076..466b351 100644
--- a/lib/ext/Net/LDAP3.php
+++ b/lib/ext/Net/LDAP3.php
@@ -714,10 +714,7 @@ class Net_LDAP3
public function get_entry_attribute($subject_dn, $attribute)
{
- $this->config_set('return_attributes', $attribute);
- $entries = $this->search($subject_dn, '(objectclass=*)', 'base')->entries(TRUE);
- $entry_dn = key($entries);
- $entry = $entries[$entry_dn];
+ $entry = $this->get_entry_attributes($subject_dn, (array)$attribute);
return $entry[$attribute];
}
@@ -725,9 +722,15 @@ class Net_LDAP3
public function get_entry_attributes($subject_dn, $attributes)
{
$this->config_set('return_attributes', $attributes);
- $entries = $this->search($subject_dn, '(objectclass=*)', 'base')->entries(TRUE);
+ $result = $this->search($subject_dn, '(objectclass=*)', 'base');
+
+ if (!$result) {
+ return array();
+ }
+
+ $entries = $result->entries(true);
$entry_dn = key($entries);
- $entry = $entries[$entry_dn];
+ $entry = $entries[$entry_dn];
return $entry;
}