Fixed dynamic group ldap access (#23450)

* Fixed dynamic group ldap access

getUserGroups:
Using $userDN instead of $uid to query LDAP
Converting groupDN to group name using API instead of substring
Removing cache processing at the end of the method

* Fixing group handling

added back the cache processing and fixed

* fixed possible indention problem

spaces -> tab conversion

* formatting, white-space changes only
This commit is contained in:
blizzz 2016-05-17 23:09:36 +02:00 committed by Thomas Müller
parent d5506b605f
commit 8ce8a05dab
1 changed files with 11 additions and 9 deletions

View File

@ -469,16 +469,17 @@ class GROUP_LDAP extends BackendUtility implements \OCP\GroupInterface {
// apply filter via ldap search to see if this user is in this // apply filter via ldap search to see if this user is in this
// dynamic group // dynamic group
$userMatch = $this->access->readAttribute( $userMatch = $this->access->readAttribute(
$uid, $userDN,
$this->access->connection->ldapUserDisplayName, $this->access->connection->ldapUserDisplayName,
$memberUrlFilter $memberUrlFilter
); );
if ($userMatch !== false) { if ($userMatch !== false) {
// match found so this user is in this group // match found so this user is in this group
$pos = strpos($dynamicGroup['dn'][0], ','); $groupName = $this->access->dn2groupname($dynamicGroup['dn'][0]);
if ($pos !== false) { if(is_string($groupName)) {
$membershipGroup = substr($dynamicGroup['dn'][0],3,$pos-3); // be sure to never return false if the dn could not be
$groups[] = $membershipGroup; // resolved to a name, for whatever reason.
$groups[] = $groupName;
} }
} }
} else { } else {
@ -530,11 +531,12 @@ class GROUP_LDAP extends BackendUtility implements \OCP\GroupInterface {
} }
if(isset($this->cachedGroupsByMember[$uid])) { if(isset($this->cachedGroupsByMember[$uid])) {
$groups = $this->cachedGroupsByMember[$uid]; $groups[] = $this->cachedGroupsByMember[$uid];
} else { } else {
$groups = array_values($this->getGroupsByMember($uid)); $groupsByMember = array_values($this->getGroupsByMember($uid));
$groups = $this->access->ownCloudGroupNames($groups); $groupsByMember = $this->access->ownCloudGroupNames($groupsByMember);
$this->cachedGroupsByMember[$uid] = $groups; $this->cachedGroupsByMember[$uid] = $groupsByMember;
$groups = array_merge($groups, $groupsByMember);
} }
if($primaryGroup !== false) { if($primaryGroup !== false) {