- 
          
- 
                Notifications
    You must be signed in to change notification settings 
- Fork 4.6k
Open
Labels
1. to developAccepted and waiting to be taken care ofAccepted and waiting to be taken care ofenhancementfeature: ldapfeature: users and groupsneeds reviewNeeds review to determine if still applicable or covered by other IssuesNeeds review to determine if still applicable or covered by other Issuesperformance 🚀
Description
there a lot of groups、members in my AD, when i debug code ,i find displayNamesInGroup execution takes too long,should we change this function,  do not get all displayname then filter. i suggest change this ,
1.get groupdn by gid
2.get users by filter with -searchBase or groupdn
	 * get a list of all display names in a group
	 *
	 * @param string $gid
	 * @param string $search
	 * @param int $limit
	 * @param int $offset
	 * @return array an array of display names (value) and user ids (key)
	 */
	public function displayNamesInGroup($gid, $search = '', $limit = -1, $offset = 0) {
 		$group = $this->get($gid);
		if (is_null($group)) {
			return [];
		}
		$search = trim($search);
		$groupUsers = [];
		if (!empty($search)) {
			// only user backends have the capability to do a complex search for users
			$searchOffset = 0;
			$searchLimit = $limit * 100;
			if ($limit === -1) {
				$searchLimit = 500;
			}
			do {
				$filteredUsers = $this->userManager->searchDisplayName($search, $searchLimit, $searchOffset);
				foreach ($filteredUsers as $filteredUser) {
					if ($group->inGroup($filteredUser)) {
						$groupUsers[] = $filteredUser;
					}
				}
				$searchOffset += $searchLimit;
			} while (count($groupUsers) < $searchLimit + $offset && count($filteredUsers) >= $searchLimit);
			if ($limit === -1) {
				$groupUsers = array_slice($groupUsers, $offset);
			} else {
				$groupUsers = array_slice($groupUsers, $offset, $limit);
			}
		} else {
			$groupUsers = $group->searchUsers('', $limit, $offset);
		}
		$matchingUsers = [];
		foreach ($groupUsers as $groupUser) {
			$matchingUsers[(string) $groupUser->getUID()] = $groupUser->getDisplayName();
		}
		return $matchingUsers;
	}
Metadata
Metadata
Assignees
Labels
1. to developAccepted and waiting to be taken care ofAccepted and waiting to be taken care ofenhancementfeature: ldapfeature: users and groupsneeds reviewNeeds review to determine if still applicable or covered by other IssuesNeeds review to determine if still applicable or covered by other Issuesperformance 🚀