on * [cn=bob,dc=example,dc=com] => on * etc. * - server_id */ require realpath( 'common.php' ); $server_id = $_POST['server_id']; check_server_id( $server_id ) or pla_error( $lang['bad_server_id'] ); if( is_server_read_only( $server_id ) ) pla_error( "Deletes not allowed in read only mode." ); have_auth_info( $server_id ) or pla_error( $lang['no_enough_login_info'] ); pla_ldap_connect( $server_id ) or pla_error( $lang['could_not_connect'] ); $confirmed = isset( $_POST['confirmed'] ) ? true : false; isset( $_POST['mass_delete'] ) or pla_error( "Error in calling mass_delete.php. Missing mass_delete in POST vars." ); $mass_delete = $_POST['mass_delete']; is_array( $mass_delete ) or pla_error( "mass_delete variable is not an array in POST vars!" ); $ds = pla_ldap_connect( $server_id ); mass_delete_enabled( $server_id ) or pla_error( "Mass deletion is not enabled. Please enable it in config.php before proceeding. " ); $server_name = $servers[ $server_id ][ 'name' ]; session_start(); require realpath( 'header.php' ); echo "
\n"; echo ""; echo "\n"; $successfully_delete_dns = array(); $failed_dns = array(); if( ! is_array( $mass_delete ) ) pla_error( "Malformed mass_delete array" ); if( count( $mass_delete ) == 0 ) { echo "
"; echo "You did not select any entries to delete. "; die(); } foreach( $mass_delete as $dn => $junk ) { echo "Deleting " . htmlspecialchars($dn) . "... "; flush(); if( true === preEntryDelete( $server_id, $dn ) ) { $success = @ldap_delete( $ds, $dn ); if( $success ) { postEntryDelete( $server_id, $dn ); echo "success.
\n"; $successfully_delete_dns[] = $dn; } else { echo "failed.\n"; echo "(" . ldap_error( $ds ) . ")
\n"; $failed_dns[] = $dn; } } flush(); } echo ""; echo "\n"; $failed_count = count( $failed_dns ); $total_count = count( $mass_delete ); if( $failed_count > 0 ) { echo "\n"; echo "$failed_count of $total_count entries failed to be deleted.\n"; } else { echo "\n"; echo "All entries deleted successfully!\n"; } // kill the deleted DNs from the tree browser session variable and // refresh the tree viewer frame (left_frame) if( session_is_registered( 'tree' ) ) { $tree = $_SESSION['tree']; foreach( $successfully_delete_dns as $dn ) { // 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; session_write_close(); ?> Confirm mass delete of $n entries on server '$server_name'\n"; ?>Do you really want to delete ?