2009-06-30 09:22:30 +00:00
|
|
|
<?php
|
|
|
|
// $Header: /cvsroot/phpldapadmin/phpldapadmin/delete.php,v 1.18 2004/08/15 17:35:25 uugdave Exp $
|
|
|
|
|
2009-06-30 08:05:37 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* delete.php
|
|
|
|
* Deletes a DN and presents a "job's done" message.
|
|
|
|
*
|
|
|
|
* Variables that come in as POST vars:
|
|
|
|
* - dn (rawurlencoded)
|
|
|
|
* - server_id
|
|
|
|
*/
|
|
|
|
|
2009-06-30 08:09:20 +00:00
|
|
|
require realpath( 'common.php' );
|
2009-06-30 08:05:37 +00:00
|
|
|
|
2009-06-30 08:09:20 +00:00
|
|
|
$dn = $_POST['dn'];
|
|
|
|
$encoded_dn = rawurlencode( $dn );
|
2009-06-30 08:05:37 +00:00
|
|
|
$server_id = $_POST['server_id'];
|
|
|
|
|
|
|
|
if( $dn === null )
|
2009-06-30 08:09:20 +00:00
|
|
|
pla_error( $lang['you_must_specify_a_dn'] );
|
2009-06-30 08:05:37 +00:00
|
|
|
|
2009-06-30 08:07:14 +00:00
|
|
|
if( is_server_read_only( $server_id ) )
|
2009-06-30 08:09:20 +00:00
|
|
|
pla_error( $lang['no_updates_in_read_only_mode'] );
|
2009-06-30 08:07:14 +00:00
|
|
|
|
2009-06-30 08:09:20 +00:00
|
|
|
check_server_id( $server_id ) or pla_error( $lang['bad_server_id'] );
|
|
|
|
have_auth_info( $server_id ) or pla_error( $lang['not_enough_login_info'] );
|
2009-06-30 09:22:30 +00:00
|
|
|
dn_exists( $server_id, $dn ) or pla_error( sprintf( $lang['no_such_entry'], '<b>' . pretty_print_dn( $dn ) . '</b>' ) );
|
2009-06-30 08:05:37 +00:00
|
|
|
|
2009-06-30 09:22:30 +00:00
|
|
|
$ds = pla_ldap_connect( $server_id );
|
|
|
|
pla_ldap_connection_is_error( $ds );
|
2009-06-30 08:09:20 +00:00
|
|
|
|
|
|
|
// Check the user-defined custom callback first.
|
|
|
|
if( true === preEntryDelete( $server_id, $dn ) ) {
|
|
|
|
$del_result = @ldap_delete( $ds, $dn );
|
|
|
|
} else {
|
|
|
|
exit;
|
|
|
|
}
|
2009-06-30 08:05:37 +00:00
|
|
|
|
|
|
|
if( $del_result )
|
|
|
|
{
|
2009-06-30 08:09:20 +00:00
|
|
|
// Custom callback
|
|
|
|
postEntryDelete( $server_id, $dn );
|
|
|
|
|
2009-06-30 08:05:37 +00:00
|
|
|
// kill the DN from the tree browser session variable and
|
|
|
|
// refresh the tree viewer frame (left_frame)
|
|
|
|
|
2009-06-30 09:22:30 +00:00
|
|
|
if( array_key_exists( 'tree', $_SESSION ) )
|
2009-06-30 08:05:37 +00:00
|
|
|
{
|
|
|
|
$tree = $_SESSION['tree'];
|
2009-06-30 08:10:17 +00:00
|
|
|
if( isset( $tree[$server_id] ) && is_array( $tree[$server_id] ) ) {
|
|
|
|
|
|
|
|
// does it have children? (it shouldn't, but hey, you never know)
|
|
|
|
if( isset( $tree[$server_id][$dn] ) )
|
|
|
|
unset( $tree[$server_id][$dn] );
|
|
|
|
|
|
|
|
// search and destroy
|
|
|
|
foreach( $tree[$server_id] as $tree_dn => $subtree )
|
|
|
|
foreach( $subtree as $key => $sub_tree_dn )
|
|
|
|
if( 0 == strcasecmp( $sub_tree_dn, $dn ) )
|
|
|
|
unset( $tree[$server_id][$tree_dn][$key] );
|
|
|
|
$_SESSION['tree'] = $tree;
|
|
|
|
}
|
2009-06-30 08:09:20 +00:00
|
|
|
session_write_close();
|
2009-06-30 08:05:37 +00:00
|
|
|
}
|
|
|
|
|
2009-06-30 09:22:30 +00:00
|
|
|
include './header.php';
|
2009-06-30 08:05:37 +00:00
|
|
|
|
|
|
|
?>
|
|
|
|
|
|
|
|
<script language="javascript">
|
|
|
|
parent.left_frame.location.reload();
|
|
|
|
</script>
|
|
|
|
|
2009-06-30 08:09:20 +00:00
|
|
|
<br />
|
|
|
|
<br />
|
2009-06-30 09:22:30 +00:00
|
|
|
<center><?php echo sprintf( $lang['entry_deleted_successfully'], '<b>' .pretty_print_dn($dn) . '</b>' ); ?></center>
|
2009-06-30 08:05:37 +00:00
|
|
|
|
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
|
|
} else {
|
2009-06-30 09:22:30 +00:00
|
|
|
pla_error( sprintf( $lang['could_not_delete_entry'], '<b>' . pretty_print_dn( $dn ) . '</b>' ),
|
2009-06-30 08:09:20 +00:00
|
|
|
ldap_error( $ds ),
|
|
|
|
ldap_errno( $ds ) );
|
2009-06-30 08:05:37 +00:00
|
|
|
}
|