/** * @return boolean * @param ResourceBundle $connection * @param string $connection * @param boolean $recursive */ public function deleteRecord($connection, $dn, $recursive = false) { if ($recursive == false) { return ldap_delete($connection, $dn); } else { $sr = ldap_list($connection, $dn, "ObjectClass=*", array("")); $info = ldap_get_entries($connection, $sr); for ($i = 0; $i < $info['count']; $i++) { $result = myldap_delete($connection, $info[$i]['dn'], $recursive); if (!$result) { return $result; } } return ldap_delete($connection, $dn); } }
/** * deletes an entryfrom ldap - optional with recursion * * @author Original by <*****@*****.**> */ function ldap_full_delete($ds, $dn, $recursive = false) { if ($recursive == false) { return ldap_delete($ds, $dn); } else { //searching for sub entries $sr = ldap_list($ds, $dn, "ObjectClass=*", array("")); $info = ldap_get_entries($ds, $sr); for ($i = 0; $i < $info['count']; $i++) { //deleting recursively sub entries $result = myldap_delete($ds, $info[$i]['dn'], $recursive); if (!$result) { //return result code, if delete fails return $result; } } return ldap_delete($ds, $dn); } }