diff options
author | Arthur Schiwon <blizzz@owncloud.com> | 2015-04-14 14:40:37 +0200 |
---|---|---|
committer | Morris Jobke <hey@morrisjobke.de> | 2015-05-19 12:56:07 +0200 |
commit | 6b218039ba4a49cd2af4a3dbceb9c41139a5848f (patch) | |
tree | e4e55d23b8afddc0f0ba91b9ef61629ed5d17c4f /apps/user_ldap/group_ldap.php | |
parent | d90b83725f87825a68b51a32228270d9e9a82ac6 (diff) | |
download | nextcloud-server-6b218039ba4a49cd2af4a3dbceb9c41139a5848f.tar.gz nextcloud-server-6b218039ba4a49cd2af4a3dbceb9c41139a5848f.zip |
Fixes returns of group memberships and counting if all members have the specific groups as primary set.
Diffstat (limited to 'apps/user_ldap/group_ldap.php')
-rw-r--r-- | apps/user_ldap/group_ldap.php | 16 |
1 files changed, 7 insertions, 9 deletions
diff --git a/apps/user_ldap/group_ldap.php b/apps/user_ldap/group_ldap.php index 8f56e01bf3d..182142cb80a 100644 --- a/apps/user_ldap/group_ldap.php +++ b/apps/user_ldap/group_ldap.php @@ -292,12 +292,13 @@ class GROUP_LDAP extends BackendUtility implements \OCP\GroupInterface { public function getUsersInPrimaryGroup($groupDN, $search = '', $limit = -1, $offset = 0) { try { $filter = $this->prepareFilterForUsersInPrimaryGroup($groupDN, $search); - return $this->access->fetchListOfUsers( + $users = $this->access->fetchListOfUsers( $filter, array($this->access->connection->ldapUserDisplayName, 'dn'), $limit, $offset ); + return $this->access->ownCloudUserNames($users); } catch (\Exception $e) { return array(); } @@ -476,8 +477,9 @@ class GROUP_LDAP extends BackendUtility implements \OCP\GroupInterface { return array(); } + $primaryUsers = $this->getUsersInPrimaryGroup($groupDN, $search, $limit, $offset); $members = array_keys($this->_groupMembers($groupDN)); - if(!$members) { + if(!$members && empty($primaryUsers)) { //in case users could not be retrieved, return empty result set $this->access->connection->writeToCache($cacheKey, array()); return array(); @@ -517,9 +519,6 @@ class GROUP_LDAP extends BackendUtility implements \OCP\GroupInterface { natsort($groupUsers); $this->access->connection->writeToCache('usersInGroup-'.$gid.'-'.$search, $groupUsers); $groupUsers = array_slice($groupUsers, $offset, $limit); - - //and get users that have the group as primary - $primaryUsers = $this->getUsersInPrimaryGroup($groupDN, $search, $limit, $offset); $groupUsers = array_unique(array_merge($groupUsers, $primaryUsers)); $this->access->connection->writeToCache($cacheKey, $groupUsers); @@ -551,16 +550,15 @@ class GROUP_LDAP extends BackendUtility implements \OCP\GroupInterface { } $members = array_keys($this->_groupMembers($groupDN)); - if(!$members) { + $primaryUserCount = $this->countUsersInPrimaryGroup($groupDN, ''); + if(!$members && $primaryUserCount === 0) { //in case users could not be retrieved, return empty result set $this->access->connection->writeToCache($cacheKey, false); return false; } if(empty($search)) { - $primaryUsers = $this->countUsersInPrimaryGroup($groupDN, ''); - $groupUsers = count($members) + $primaryUsers; - + $groupUsers = count($members) + $primaryUserCount; $this->access->connection->writeToCache($cacheKey, $groupUsers); return $groupUsers; } |