make deletion safer

This commit is contained in:
Roland Gruber 2011-09-27 18:21:37 +00:00
parent 6264203373
commit 933d8224b8
2 changed files with 11 additions and 0 deletions

View File

@ -51,6 +51,13 @@ foreach ($request['parent'] as $dn) {
}
function pla_rdelete($server,$dn) {
if (($dn == null) || ($dn == '')) {
system_message(array(
'title'=>_('Entry does not exist'),
'body'=>sprintf('%s (%s)',_('Unable to delete entry, it does not exist'),$dn),
'type'=>'error'));
return false;
}
# We delete all children, not only the visible children in the tree
$children = $server->getContainerContents($dn,null,0,'(objectClass=*)',LDAP_DEREF_NEVER);

View File

@ -305,6 +305,10 @@ function getChildCount($dn) {
*/
function deleteDN($dn) {
$errors = array();
if (($dn == null) || ($dn == '')) {
$errors[] = array('ERROR', _('Entry does not exist'));
return $errors;
}
$sr = @ldap_list($_SESSION['ldap']->server(), $dn, 'objectClass=*', array('dn'), 0, 0, 0, LDAP_DEREF_NEVER);
if ($sr) {
$entries = ldap_get_entries($_SESSION['ldap']->server(), $sr);