/**
  * Delete an entry from the directory.
  *
  * @param string $dn
  *   The distinguished name of an LDAP entry.
  * @param boolean $recursive
  *   If TRUE, all children of the given DN will be deleted before attempting
  *   to delete the DN.
  *
  * @return boolean
  *   TRUE on success.
  *
  * @throw SimpleLdapException
  */
 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);
 }