4343use OC \AppFramework \Http ;
4444use OC \ForbiddenException ;
4545use OC \Security \IdentityProof \Manager ;
46+ use OCA \User_LDAP \User_Proxy ;
4647use OCP \App \IAppManager ;
4748use OCP \AppFramework \Controller ;
4849use OCP \AppFramework \Http \DataResponse ;
5354use OCP \IGroupManager ;
5455use OCP \IL10N ;
5556use OCP \IRequest ;
56- use OCP \IURLGenerator ;
5757use OCP \IUser ;
5858use OCP \IUserManager ;
5959use 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