diff options
author | Arthur Schiwon <blizzz@owncloud.com> | 2015-10-07 19:57:49 +0300 |
---|---|---|
committer | Morris Jobke <hey@morrisjobke.de> | 2015-10-22 13:02:48 +0300 |
commit | 6ccc5a6cd34deea57f0ae7a64c10a16e7ca5c30f (patch) | |
tree | bf13820bcb20a084a5d3a8e95d6e093d45a563ee | |
parent | 7ccd52db253ad6909092e87e89a17d8c078e01f4 (diff) |
allow an attribute to return more than one value
-rw-r--r-- | apps/user_ldap/lib/access.php | 41 | ||||
-rw-r--r-- | apps/user_ldap/lib/wizard.php | 2 |
2 files changed, 14 insertions, 29 deletions
diff --git a/apps/user_ldap/lib/access.php b/apps/user_ldap/lib/access.php index c1c6a8fac45..0005bad2660 100644 --- a/apps/user_ldap/lib/access.php +++ b/apps/user_ldap/lib/access.php @@ -720,6 +720,9 @@ class Access extends LDAPUtility implements user\IUserTools { if($manyAttributes) { return $list; } else { + $list = array_reduce($list, function($carry, $item) { + $carry[] = $item[0]; + }, array()); return array_unique($list, SORT_LOCALE_STRING); } } @@ -992,44 +995,26 @@ class Access extends LDAPUtility implements user\IUserTools { if(!is_null($attr)) { $selection = array(); - $multiArray = false; - if(count($attr) > 1) { - $multiArray = true; - $i = 0; - } + $i = 0; foreach($findings as $item) { if(!is_array($item)) { continue; } $item = \OCP\Util::mb_array_change_key_case($item, MB_CASE_LOWER, 'UTF-8'); - - if($multiArray) { - foreach($attr as $key) { - $key = mb_strtolower($key, 'UTF-8'); - if(isset($item[$key])) { - if($key !== 'dn') { - $selection[$i][$key] = $this->resemblesDN($key) ? - $this->sanitizeDN($item[$key][0]) - : $item[$key][0]; - } else { - $selection[$i][$key] = $this->sanitizeDN($item[$key]); - } - } - - } - $i++; - } else { - //tribute to case insensitivity - $key = mb_strtolower($attr[0], 'UTF-8'); - + foreach($attr as $key) { + $key = mb_strtolower($key, 'UTF-8'); if(isset($item[$key])) { - if($this->resemblesDN($key)) { - $selection[] = $this->sanitizeDN($item[$key]); + if($key !== 'dn') { + $selection[$i][$key] = $this->resemblesDN($key) ? + $this->sanitizeDN($item[$key]) + : $item[$key]; } else { - $selection[] = $item[$key]; + $selection[$i][$key] = $this->sanitizeDN($item[$key]); } } + } + $i++; } $findings = $selection; } diff --git a/apps/user_ldap/lib/wizard.php b/apps/user_ldap/lib/wizard.php index 6ca84c8718f..2b0b888c42e 100644 --- a/apps/user_ldap/lib/wizard.php +++ b/apps/user_ldap/lib/wizard.php @@ -434,7 +434,7 @@ class Wizard extends LDAPUtility { // detection will fail later $result = $this->access->searchGroups($filter, array('cn', 'dn'), $limit, $offset); foreach($result as $item) { - $groupNames[] = $item['cn']; + $groupNames[] = $item['cn'][0]; $groupEntries[] = $item; } $offset += $limit; |