/**
* Creates the entry in LDAP.
*
* @return bool
*/
public function create()
{
if (empty($this->getDn())) {
// If the model doesn't currently have a DN,
// we'll create a new one automatically.
$dn = $this->getDnBuilder();
// We'll set the base of the DN to the query's base DN.
$dn->setBase($this->query->getDn());
// Then we'll add the entry's common name attribute.
$dn->addCn($this->getCommonName());
// Set the new DN.
$this->setDn($dn);
}
// Create the entry.
$created = $this->query->getConnection()->add($this->getDn(), $this->getAttributes());
if ($created) {
// If the entry was created we'll re-sync
// the models attributes from AD.
$this->syncRaw();
return true;
}
return false;
}