2009-06-30 09:22:30 +00:00
|
|
|
<?php
|
2009-06-30 11:52:55 +00:00
|
|
|
// $Header: /cvsroot/phpldapadmin/phpldapadmin/htdocs/delete.php,v 1.27.2.3 2008/12/12 12:20:22 wurley Exp $
|
2009-06-30 08:05:37 +00:00
|
|
|
|
2009-06-30 09:29:51 +00:00
|
|
|
/**
|
2009-06-30 08:05:37 +00:00
|
|
|
* Deletes a DN and presents a "job's done" message.
|
|
|
|
*
|
|
|
|
* Variables that come in as POST vars:
|
|
|
|
* - dn (rawurlencoded)
|
2009-06-30 09:29:51 +00:00
|
|
|
*
|
|
|
|
* @package phpLDAPadmin
|
|
|
|
*/
|
|
|
|
/**
|
2009-06-30 08:05:37 +00:00
|
|
|
*/
|
|
|
|
|
2009-06-30 09:29:51 +00:00
|
|
|
require './common.php';
|
2009-06-30 08:05:37 +00:00
|
|
|
|
2009-06-30 09:29:51 +00:00
|
|
|
if ($ldapserver->isReadOnly())
|
2009-06-30 11:52:55 +00:00
|
|
|
error(_('You cannot perform updates while server is in read-only mode'),'error','index.php');
|
2009-06-30 08:05:37 +00:00
|
|
|
|
2009-06-30 11:46:44 +00:00
|
|
|
if (! $_SESSION[APPCONFIG]->isCommandAvailable('entry_delete', 'simple_delete'))
|
2009-06-30 11:52:55 +00:00
|
|
|
error(sprintf('%s%s %s',_('This operation is not permitted by the configuration'),_(':'),_('delete entry')),'error','index.php');
|
2009-06-30 08:07:14 +00:00
|
|
|
|
2009-06-30 11:52:55 +00:00
|
|
|
$entry = array();
|
2009-06-30 10:46:00 +00:00
|
|
|
$entry['dn'] = get_request('dn');
|
|
|
|
|
|
|
|
if (! $entry['dn'])
|
2009-06-30 11:52:55 +00:00
|
|
|
error(_('You must specify a DN'),'error','index.php');
|
2009-06-30 08:05:37 +00:00
|
|
|
|
2009-06-30 10:46:00 +00:00
|
|
|
if (! $ldapserver->dnExists($entry['dn']))
|
2009-06-30 11:52:55 +00:00
|
|
|
error(sprintf('%s (%s)',_('No such entry.'),'<b>'.pretty_print_dn($entry['dn']).'</b>'),'error','index.php');
|
2009-06-30 08:05:37 +00:00
|
|
|
|
2009-06-30 10:26:08 +00:00
|
|
|
# Check the user-defined custom callback first.
|
2009-06-30 10:46:00 +00:00
|
|
|
if (run_hook('pre_entry_delete',array('server_id'=>$ldapserver->server_id,'dn'=>$entry['dn'])))
|
|
|
|
$result = $ldapserver->delete($entry['dn']);
|
2009-06-30 09:29:51 +00:00
|
|
|
else
|
2009-06-30 11:52:55 +00:00
|
|
|
error(sprintf(_('Could not delete the entry: %s'),'<b>'.pretty_print_dn($entry['dn']).'</b>'),'error','index.php');
|
2009-06-30 08:09:20 +00:00
|
|
|
|
2009-06-30 10:46:00 +00:00
|
|
|
if ($result) {
|
2009-06-30 09:29:51 +00:00
|
|
|
# Custom callback
|
2009-06-30 10:46:00 +00:00
|
|
|
run_hook('post_entry_delete',
|
|
|
|
array('server_id'=>$ldapserver->server_id,'dn'=>$entry['dn']));
|
2009-06-30 09:29:51 +00:00
|
|
|
|
2009-06-30 10:46:00 +00:00
|
|
|
system_message(array(
|
|
|
|
'title'=>_('Delete DN'),
|
|
|
|
'body'=>_('Successfully deleted DN ').sprintf('<b>%s</b>',$entry['dn']),
|
|
|
|
'type'=>'info'),
|
2009-06-30 11:46:44 +00:00
|
|
|
sprintf('index.php?server_id=%s',$ldapserver->server_id));
|
2009-06-30 08:05:37 +00:00
|
|
|
|
|
|
|
} else {
|
2009-06-30 11:52:55 +00:00
|
|
|
system_message(array(
|
|
|
|
'title'=>_('Could not delete the entry.').sprintf(' (%s)',pretty_print_dn($entry['dn'])),
|
|
|
|
'body'=>ldap_error_msg($ldapserver->error(),$ldapserver->errno()),
|
|
|
|
'type'=>'error'));
|
2009-06-30 08:05:37 +00:00
|
|
|
}
|
2009-06-30 09:29:51 +00:00
|
|
|
?>
|