summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJeroen van Meeuwen (Kolab Systems) <vanmeeuwen@kolabsys.com>2012-09-03 12:24:12 +0100
committerJeroen van Meeuwen (Kolab Systems) <vanmeeuwen@kolabsys.com>2012-09-03 12:24:12 +0100
commit100522862f21bcf6a67eaf057cb8a6945522af4e (patch)
treef8e8b9be1573e58c427815eaa4e51f692a321e74
parentc7c715d78cdb4e9467bfb67ac100b47d9b5a3cd0 (diff)
downloadwebadmin-100522862f21bcf6a67eaf057cb8a6945522af4e.tar.gz
Teach functions get_entry_attribute() and get_entry_attributes() to treat a Net_LDAP3_Result like it deserves
-rw-r--r--lib/ext/Net/LDAP3.php28
1 files changed, 14 insertions, 14 deletions
diff --git a/lib/ext/Net/LDAP3.php b/lib/ext/Net/LDAP3.php
index 2ea7833..f917dec 100644
--- a/lib/ext/Net/LDAP3.php
+++ b/lib/ext/Net/LDAP3.php
@@ -675,27 +675,22 @@ class Net_LDAP3
public function get_entry_attribute($subject_dn, $attribute)
{
- $this->config_set('return_attributes', $attributes);
- $result = $this->search($subject_dn, '(objectclass=*)', 'base');
- $dn = key($result);
- $attr = key($result[$dn]);
+ $this->config_set('return_attributes', $attribute);
+ $entries = $this->search($subject_dn, '(objectclass=*)', 'base')->entries(TRUE);
+ $entry_dn = key($entries);
+ $entry = $entries[$entry_dn];
- return $result[$dn][$attr];
+ return $entry[$attribute];
}
public function get_entry_attributes($subject_dn, $attributes)
{
$this->config_set('return_attributes', $attributes);
- $entries = $this->search($subject_dn, '(objectclass=*)', 'base');
- $entry = $entries->entries(TRUE);
- $result = $entry[0];
-
- if (!empty($result)) {
- $result = array_pop($result);
- return $result;
- }
+ $entries = $this->search($subject_dn, '(objectclass=*)', 'base')->entries(TRUE);
+ $entry_dn = key($entries);
+ $entry = $entries[$entry_dn];
- return FALSE;
+ return $entry;
}
/*
@@ -1899,11 +1894,16 @@ class Net_LDAP3
private function supported_controls()
{
+ if (!empty($this->supported_controls)) {
+ return $this->supported_controls;
+ }
+
$this->_info("Obtaining supported controls");
$this->return_attributes = Array("supportedcontrol");
$result = $this->search("", "(objectclass=*)", 'base');
$result = $result->entries(TRUE);
$this->_info("Obtained " . count($result['']['supportedcontrol']) . " supported controls");
+ $this->supported_controls = $result['']['supportedcontrol'];
return $result['']['supportedcontrol'];
}