code/services/LDAPService.php
public function getGroups($cached = true, $attributes = [], $indexBy = 'dn')
    {
        $searchLocations = $this->config()->groups_search_locations ?: [null];
        $cache = self::get_cache();
        $results = $cache->load('groups' . md5(implode('', array_merge($searchLocations, $attributes))));

        if (!$results || !$cached) {
            $results = [];
            foreach ($searchLocations as $searchLocation) {
                $records = $this->gateway->getGroups($searchLocation, Zend\Ldap\Ldap::SEARCH_SCOPE_SUB, $attributes);
                if (!$records) {
                    continue;
                }

                foreach ($records as $record) {
                    $results[$record[$indexBy]] = $record;
                }
            }

            $cache->save($results);
        }

        return $results;
    }
public function getGroups($cached = true, $attributes = [], $indexBy = 'dn')
    {
        $searchLocations = $this->config()->groups_search_locations ?: [null];
        $cache = self::get_cache();
        $results = $cache->load('groups' . md5(implode('', array_merge($searchLocations, $attributes))));

        if (!$results || !$cached) {
            $results = [];
            foreach ($searchLocations as $searchLocation) {
                $records = $this->gateway->getGroups($searchLocation, Zend\Ldap\Ldap::SEARCH_SCOPE_SUB, $attributes);
                if (!$records) {
                    continue;
                }

                foreach ($records as $record) {
                    $results[$record[$indexBy]] = $record;
                }
            }

            $cache->save($results);
        }

        return $results;
    }
Return all AD groups in configured search locations, including all nested groups.
Uses groups_search_locations if defined, otherwise falls back to NULL, which tells LDAPGateway
to use the default baseDn defined in the connection.

@param boolean $cached Cache the results from AD, so that subsequent calls are faster. Enabled by default.
@param array $attributes List of specific AD attributes to return. Empty array means return everything.
@param string $indexBy Attribute to use as an index.
@return array