Horde_Group_Ldap::_listUsers PHP Method

_listUsers() protected method

Returns a list of users in a group.
protected _listUsers ( mixed $gid ) : array
$gid mixed A group ID.
return array List of group users.
    protected function _listUsers($gid)
    {
        $attr = $this->_params['memberuid'];
        try {
            $entry = $this->_ldap->getEntry($gid, array($attr));
            if (!$entry->exists($attr)) {
                return array();
            }
            if (empty($this->_params['attrisdn'])) {
                return $entry->getValue($attr, 'all');
            }
            $users = array();
            foreach ($entry->getValue($attr, 'all') as $user) {
                $dn = Horde_Ldap_Util::explodeDN($user, array('onlyvalues' => true));
                // Very simplified approach: assume the first element of the DN
                // contains the user ID.
                $user = $dn[0];
                // Check for multi-value RDNs.
                if (is_array($element)) {
                    $user = $element[0];
                }
                $users[] = $user;
            }
            return $users;
        } catch (Horde_Exception_NotFound $e) {
            return array();
        } catch (Horde_Ldap_Exception $e) {
            throw new Horde_Group_Exception($e);
        }
    }