Horde_Group_Ldap::_create PHP Method

_create() protected method

Creates a new group.
protected _create ( string $name, string $email = null ) : mixed
$name string A group name.
$email string The group's email address.
return mixed The ID of the created group.
    protected function _create($name, $email = null)
    {
        if ($this->readOnly()) {
            throw new Horde_Group_Exception('This group backend is read-only.');
        }
        $attributes = array($this->_params['gid'] => $name, 'objectclass' => $this->_params['newgroup_objectclass'], 'gidnumber' => $this->_nextGid());
        if (!empty($email)) {
            $attributes['mail'] = $email;
        }
        $dn = Horde_Ldap::quoteDN(array(array($this->_params['gid'], $name))) . ',' . $this->_params['basedn'];
        try {
            $entry = Horde_Ldap_Entry::createFresh($dn, $attributes);
            $this->_rebind(true);
            $this->_ldap->add($entry);
            $this->_rebind(false);
        } catch (Horde_Ldap_Exception $e) {
            throw new Horde_Group_Exception($e);
        }
        return $dn;
    }