summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAleksander Machniak <machniak@kolabsys.com>2014-10-24 09:54:19 (GMT)
committerAleksander Machniak <machniak@kolabsys.com>2014-10-24 09:54:19 (GMT)
commit1e36295ff2a2ff54e3f879e36450e2552e3a2956 (patch)
tree02d44f450d0fd5b82d255119260ecc690368cac5
parent88e47d7b395f01c0fd2f599ba38f455d1479380b (diff)
downloadkolab-wap-1e36295ff2a2ff54e3f879e36450e2552e3a2956.tar.gz
Fix organizational units tree if base_dn contains items other than dc= (#3770)
-rw-r--r--lib/client/kolab_client_task_ou.php39
1 files changed, 19 insertions, 20 deletions
diff --git a/lib/client/kolab_client_task_ou.php b/lib/client/kolab_client_task_ou.php
index a286d34..2a99f92 100644
--- a/lib/client/kolab_client_task_ou.php
+++ b/lib/client/kolab_client_task_ou.php
@@ -197,7 +197,7 @@ class kolab_client_task_ou extends kolab_client_task
// build the list for sorting
foreach (array_keys($list) as $dn) {
$names = $this->explode_dn($dn);
- $sort_name = $names['domain'] . ':' . implode(',', array_reverse($names['path']));
+ $sort_name = $names['root'] . ':' . implode(',', array_reverse($names['path']));
$list[$dn] = mb_strtolower($sort_name);
}
@@ -231,10 +231,10 @@ class kolab_client_task_ou extends kolab_client_task
if ($item['level']) {
// create a parent unit entry if it does not exist (search result)
- $parent = $this->domain_dn($item['domain']);
+ $parent = $item['root'];
foreach ($item['path'] as $sub) {
- // convert special characters back into entities (#
+ // convert special characters back into entities (#3744)
$sub = str_replace(',', "\\2C", $sub);
$parent = "ou=$sub,$parent";
@@ -263,39 +263,38 @@ class kolab_client_task_ou extends kolab_client_task
$items = $this->explode_dn($dn);
return array(
- 'name' => array_shift($items['path']),
- 'path' => array_reverse($items['path']),
- 'level' => count($items['path']),
- 'domain' => $items['domain'],
+ 'name' => array_shift($items['path']),
+ 'path' => array_reverse($items['path']),
+ 'level' => count($items['path']),
+ 'root' => $items['root'],
);
}
/**
- * Converts domain name into DN string
+ * Tokenizes OU's DN string
*/
- private function domain_dn($domain)
- {
- return "dc=" . implode(',dc=', explode('.', $domain));
- }
-
private function explode_dn($dn)
{
- $path = kolab_utils::explode_dn($dn);
- $domain = array();
+ $path = kolab_utils::explode_dn($dn);
+ $root = array();
foreach ($path as $idx => $item) {
- if (strpos($item, 'dc=') === 0) {
+ $pos = strpos($item, '=');
+ $key = substr($item, 0, $pos);
+
+ if ($key != 'ou') {
unset($path[$idx]);
- $domain[] = substr($item, 3);
+ // convert special characters back into entities (#3744)
+ $root[] = str_replace(',', "\\2C", $item);
}
else {
- $path[$idx] = substr($item, 3);
+ $path[$idx] = substr($item, $pos + 1);
}
}
return array(
- 'domain' => implode('.', $domain),
- 'path' => $path,
+ 'root' => implode(',', $root),
+ 'path' => $path,
);
}
}