Horde_Group_Ldap::_nextGid PHP Method

_nextGid() protected method

Searches existing groups for the highest gidnumber, and returns one higher.
protected _nextGid ( ) : integer
return integer The next group ID.
    protected function _nextGid()
    {
        try {
            $search = $this->_ldap->search($this->_params['basedn'], $this->_filter, array('attributes' => array('gidnumber')));
        } catch (Horde_Ldap_Exception $e) {
            throw new Horde_Group_Exception($e);
        }
        if (!$search->count()) {
            return 1;
        }
        $nextgid = 0;
        foreach ($search as $entry) {
            $nextgid = max($nextgid, $entry->getValue('gidnumber', 'single'));
        }
        return $nextgid + 1;
    }