Skip to content

Commit 1b74bfc

Browse files
committed
do not trigger counting on LDAP
it's probably too many, degregading performance Signed-off-by: Arthur Schiwon <blizzz@arthur-schiwon.de>
1 parent 0757c52 commit 1b74bfc

1 file changed

Lines changed: 11 additions & 6 deletions

File tree

settings/Controller/UsersController.php

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@
4343
use OC\AppFramework\Http;
4444
use OC\ForbiddenException;
4545
use OC\Security\IdentityProof\Manager;
46+
use OCA\User_LDAP\User_Proxy;
4647
use OCP\App\IAppManager;
4748
use OCP\AppFramework\Controller;
4849
use OCP\AppFramework\Http\DataResponse;
@@ -53,7 +54,6 @@
5354
use OCP\IGroupManager;
5455
use OCP\IL10N;
5556
use OCP\IRequest;
56-
use OCP\IURLGenerator;
5757
use OCP\IUser;
5858
use OCP\IUserManager;
5959
use OCP\IUserSession;
@@ -153,14 +153,13 @@ public function usersList() {
153153

154154
/* SORT OPTION: SORT_USERCOUNT or SORT_GROUPNAME */
155155
$sortGroupsBy = \OC\Group\MetaData::SORT_USERCOUNT;
156+
$isLDAPUsed = false;
156157
if ($this->config->getSystemValue('sort_groups_by_name', false)) {
157158
$sortGroupsBy = \OC\Group\MetaData::SORT_GROUPNAME;
158159
} else {
159-
$isLDAPUsed = false;
160160
if ($this->appManager->isEnabledForUser('user_ldap')) {
161161
$isLDAPUsed =
162-
$this->groupManager->isBackendUsed('\OCA\User_LDAP\Group_LDAP')
163-
|| $this->groupManager->isBackendUsed('\OCA\User_LDAP\Group_Proxy');
162+
$this->groupManager->isBackendUsed('\OCA\User_LDAP\Group_Proxy');
164163
if ($isLDAPUsed) {
165164
// LDAP user count can be slow, so we sort by group name here
166165
$sortGroupsBy = \OC\Group\MetaData::SORT_GROUPNAME;
@@ -185,10 +184,16 @@ public function usersList() {
185184

186185
$groupsInfo->setSorting($sortGroupsBy);
187186
list($adminGroup, $groups) = $groupsInfo->get();
187+
188+
if(!$isLDAPUsed && $this->appManager->isEnabledForUser('user_ldap')) {
189+
$isLDAPUsed = (bool)array_reduce($this->userManager->getBackends(), function ($ldapFound, $backend) {
190+
return $ldapFound || $backend instanceof User_Proxy;
191+
});
192+
}
188193

189194
if ($this->isAdmin) {
190195
$disabledUsers = $isLDAPUsed ? 0 : $this->userManager->countDisabledUsers();
191-
$userCount = array_reduce($this->userManager->countUsers(), function($v, $w) {
196+
$userCount = $isLDAPUsed ? 0 : array_reduce($this->userManager->countUsers(), function($v, $w) {
192197
return $v + (int)$w;
193198
}, 0);
194199
} else {
@@ -208,7 +213,7 @@ public function usersList() {
208213
$userCount = -1; // we also lower from one the total count
209214
}
210215
};
211-
$userCount += $this->userManager->countUsersOfGroups($groupsInfo->getGroups());
216+
$userCount += $isLDAPUsed ? 0 : $this->userManager->countUsersOfGroups($groupsInfo->getGroups());
212217
$disabledUsers = $isLDAPUsed ? 0 : $this->userManager->countDisabledUsersOfGroups($groupsNames);
213218
}
214219
$disabledUsersGroup = [

0 commit comments

Comments
 (0)