public function SimpleLdapServer::delete in Simple LDAP 7
Same name and namespace in other branches
- 7.2 SimpleLdapServer.class.php \SimpleLdapServer::delete()
Delete an entry from the directory.
@throw SimpleLdapException
Parameters
string $dn: The distinguished name of an LDAP entry.
boolean $recursive: If TRUE, all children of the given DN will be deleted before attempting to delete the DN.
Return value
boolean TRUE on success.
File
- ./
SimpleLdapServer.class.php, line 515 - Class to handle LDAP server connections and related operations.
Class
- SimpleLdapServer
- Simple LDAP server class.
Code
public function delete($dn, $recursive = FALSE) {
// Make sure changes are allowed.
if ($this->readonly) {
throw new SimpleLdapException('The LDAP Server is configured as read-only');
}
// Make sure there is a valid binding.
$this
->bind();
// Delete children.
if ($recursive) {
$subentries = SimpleLdap::clean($this
->search($dn, '(objectclass=*)', 'one', array(
'dn',
)));
foreach ($subentries as $subdn => $entry) {
$this
->delete($subdn, TRUE);
}
}
// Delete the DN.
return SimpleLdap::ldap_delete($this->resource, $dn);
}