From 933d8224b8b5719b5630b6afbd53c32a3e0579be Mon Sep 17 00:00:00 2001 From: Roland Gruber Date: Tue, 27 Sep 2011 18:21:37 +0000 Subject: [PATCH] make deletion safer --- lam/templates/3rdParty/pla/htdocs/rdelete.php | 7 +++++++ lam/templates/delete.php | 4 ++++ 2 files changed, 11 insertions(+) diff --git a/lam/templates/3rdParty/pla/htdocs/rdelete.php b/lam/templates/3rdParty/pla/htdocs/rdelete.php index bb864a9d..5a40a5c5 100644 --- a/lam/templates/3rdParty/pla/htdocs/rdelete.php +++ b/lam/templates/3rdParty/pla/htdocs/rdelete.php @@ -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); diff --git a/lam/templates/delete.php b/lam/templates/delete.php index 9a1ab4e5..f9b8044d 100644 --- a/lam/templates/delete.php +++ b/lam/templates/delete.php @@ -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);