summaryrefslogtreecommitdiff
path: root/lib/Kolab/FreeBusy/DirectoryLDAP.php
diff options
context:
space:
mode:
Diffstat (limited to 'lib/Kolab/FreeBusy/DirectoryLDAP.php')
-rw-r--r--lib/Kolab/FreeBusy/DirectoryLDAP.php34
1 files changed, 28 insertions, 6 deletions
diff --git a/lib/Kolab/FreeBusy/DirectoryLDAP.php b/lib/Kolab/FreeBusy/DirectoryLDAP.php
index c155d98..c97340a 100644
--- a/lib/Kolab/FreeBusy/DirectoryLDAP.php
+++ b/lib/Kolab/FreeBusy/DirectoryLDAP.php
@@ -114,12 +114,17 @@ class DirectoryLDAP extends Directory
$this->logger->addInfo("Found " . $ldapresult->count() . " entries for $filter", $entry);
// convert entry attributes to strings and add them to the final result hash array
- foreach ($entry as $k => $v) {
- if (is_array($v) && count($v) > 1) {
- $result[$k] = array_map('strval', $v);
- }
- else if (!empty($v)) {
- $result[$k] = strval(is_array($v) ? $v[0] : $v);
+ $result += self::_compact_entry($entry);
+
+ // resolve DN attribute into the actual record
+ if (!empty($this->config['resolve_dn']) && array_key_exists($this->config['resolve_dn'], $result)) {
+ $k = $this->config['resolve_dn'];
+ $member_attr = $this->config['resolve_attribute'] ?: 'mail';
+ foreach ((array)$result[$k] as $i => $member_dn) {
+ if ($member_rec = $this->ldap->get_entry($member_dn, array($member_attr))) {
+ $member_rec = self::_compact_entry(Net_LDAP3::normalize_entry($member_rec));
+ $result[$k][$i] = $member_rec[$member_attr];
+ }
}
}
@@ -132,5 +137,22 @@ class DirectoryLDAP extends Directory
return false;
}
+ /**
+ * Helper method to convert entry attributes to simple values
+ */
+ private static function _compact_entry($entry)
+ {
+ $result = array();
+ foreach ($entry as $k => $v) {
+ if (is_array($v) && count($v) > 1) {
+ $result[$k] = array_map('strval', $v);
+ }
+ else if (!empty($v)) {
+ $result[$k] = strval(is_array($v) ? $v[0] : $v);
+ }
+ }
+ return $result;
+ }
+
}