| 
									
										
										
										
											2003-09-28 13:30:31 +00:00
										 |  |  | <?php | 
					
						
							| 
									
										
										
										
											2003-04-25 11:07:28 +00:00
										 |  |  | /* | 
					
						
							| 
									
										
										
										
											2005-03-26 11:27:15 +00:00
										 |  |  | 	$Id$ | 
					
						
							| 
									
										
										
										
											2006-08-14 17:29:45 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-10-27 18:47:12 +00:00
										 |  |  | 	This code is part of LDAP Account Manager (http://www.ldap-account-manager.org/) | 
					
						
							| 
									
										
										
										
											2006-03-03 17:30:35 +00:00
										 |  |  | 	Copyright (C) 2003 - 2006  Tilo Lutz | 
					
						
							| 
									
										
										
										
											2015-05-15 19:16:46 +00:00
										 |  |  | 	Copyright (C) 2007 - 2015  Roland Gruber | 
					
						
							| 
									
										
										
										
											2006-08-14 17:29:45 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2005-03-26 11:27:15 +00:00
										 |  |  | 	This program is free software; you can redistribute it and/or modify | 
					
						
							|  |  |  | 	it under the terms of the GNU General Public License as published by | 
					
						
							|  |  |  | 	the Free Software Foundation; either version 2 of the License, or | 
					
						
							|  |  |  | 	(at your option) any later version. | 
					
						
							| 
									
										
										
										
											2006-08-14 17:29:45 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2005-03-26 11:27:15 +00:00
										 |  |  | 	This program is distributed in the hope that it will be useful, | 
					
						
							|  |  |  | 	but WITHOUT ANY WARRANTY; without even the implied warranty of | 
					
						
							|  |  |  | 	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the | 
					
						
							|  |  |  | 	GNU General Public License for more details. | 
					
						
							| 
									
										
										
										
											2006-08-14 17:29:45 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2005-03-26 11:27:15 +00:00
										 |  |  | 	You should have received a copy of the GNU General Public License | 
					
						
							|  |  |  | 	along with this program; if not, write to the Free Software | 
					
						
							|  |  |  | 	Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA | 
					
						
							| 
									
										
										
										
											2006-08-14 17:29:45 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2005-03-26 11:27:15 +00:00
										 |  |  | */ | 
					
						
							| 
									
										
										
										
											2003-04-25 11:07:28 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2005-03-26 11:27:15 +00:00
										 |  |  | /** | 
					
						
							|  |  |  | * Used to delete accounts from LDAP tree. | 
					
						
							|  |  |  | * | 
					
						
							|  |  |  | * @author Tilo Lutz | 
					
						
							| 
									
										
										
										
											2007-02-22 18:26:23 +00:00
										 |  |  | * @author Roland Gruber | 
					
						
							| 
									
										
										
										
											2005-08-17 19:17:15 +00:00
										 |  |  | * @package main | 
					
						
							| 
									
										
										
										
											2003-04-25 11:07:28 +00:00
										 |  |  | */ | 
					
						
							| 
									
										
										
										
											2003-10-20 17:56:52 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2004-01-10 11:47:48 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2006-03-26 17:51:25 +00:00
										 |  |  | /** security functions */ | 
					
						
							|  |  |  | include_once("../lib/security.inc"); | 
					
						
							| 
									
										
										
										
											2005-08-17 19:17:15 +00:00
										 |  |  | /** account functions */ | 
					
						
							|  |  |  | include_once('../lib/account.inc'); | 
					
						
							|  |  |  | /** current configuration options */ | 
					
						
							|  |  |  | include_once('../lib/config.inc'); | 
					
						
							|  |  |  | /** message displaying */ | 
					
						
							|  |  |  | include_once('../lib/status.inc'); | 
					
						
							|  |  |  | /** LDAP connection */ | 
					
						
							|  |  |  | include_once('../lib/ldap.inc'); | 
					
						
							|  |  |  | /** lamdaemon interface */ | 
					
						
							|  |  |  | include_once('../lib/lamdaemon.inc'); | 
					
						
							|  |  |  | /** module interface */ | 
					
						
							|  |  |  | include_once('../lib/modules.inc'); | 
					
						
							| 
									
										
										
										
											2004-01-10 11:47:48 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | // Start session
 | 
					
						
							| 
									
										
										
										
											2006-03-26 17:51:25 +00:00
										 |  |  | startSecureSession(); | 
					
						
							| 
									
										
										
										
											2004-01-10 11:47:48 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2007-12-30 16:08:54 +00:00
										 |  |  | if (!checkIfWriteAccessIsAllowed()) { | 
					
						
							|  |  |  | 	die(); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2003-10-22 17:51:44 +00:00
										 |  |  | // Redirect to startpage if user is not loged in
 | 
					
						
							| 
									
										
										
										
											2014-10-25 19:17:53 +00:00
										 |  |  | if (!isLoggedIn()) { | 
					
						
							| 
									
										
										
										
											2003-10-22 17:51:44 +00:00
										 |  |  | 	metaRefresh("login.php"); | 
					
						
							| 
									
										
										
										
											2004-01-10 11:47:48 +00:00
										 |  |  | 	exit; | 
					
						
							| 
									
										
										
										
											2005-03-26 11:27:15 +00:00
										 |  |  | } | 
					
						
							| 
									
										
										
										
											2003-10-22 17:51:44 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2004-01-10 11:47:48 +00:00
										 |  |  | // Set correct language, codepages, ....
 | 
					
						
							| 
									
										
										
										
											2003-08-10 19:46:21 +00:00
										 |  |  | setlanguage(); | 
					
						
							| 
									
										
										
										
											2003-04-25 16:14:09 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-05-15 19:16:46 +00:00
										 |  |  | if (!empty($_POST)) { | 
					
						
							|  |  |  | 	validateSecurityToken(); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-03-13 21:34:13 +00:00
										 |  |  | if (isset($_POST['type']) && !preg_match('/^[a-z0-9_]+$/i', $_POST['type'])) { | 
					
						
							|  |  |  | 	logNewMessage(LOG_ERR, 'Invalid type: ' . $_POST['type']); | 
					
						
							|  |  |  | 	die(); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2007-04-21 11:04:50 +00:00
										 |  |  | if (isset($_GET['type']) && isset($_SESSION['delete_dn'])) { | 
					
						
							| 
									
										
										
										
											2012-03-13 21:34:13 +00:00
										 |  |  | 	if (!preg_match('/^[a-z0-9_]+$/i', $_GET['type'])) { | 
					
						
							|  |  |  | 		logNewMessage(LOG_ERR, 'Invalid type: ' . $_GET['type']); | 
					
						
							|  |  |  | 		die(); | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2014-01-15 20:48:52 +00:00
										 |  |  | 	if (!checkIfDeleteEntriesIsAllowed($_GET['type']) || !checkIfWriteAccessIsAllowed($_GET['type'])) { | 
					
						
							| 
									
										
										
										
											2013-05-01 12:36:17 +00:00
										 |  |  | 		logNewMessage(LOG_ERR, 'User tried to delete entries of forbidden type '. $_GET['type']); | 
					
						
							|  |  |  | 		die(); | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2004-01-10 11:47:48 +00:00
										 |  |  | 	// Create account list
 | 
					
						
							|  |  |  | 	foreach ($_SESSION['delete_dn'] as $dn) { | 
					
						
							|  |  |  | 		$start = strpos ($dn, "=")+1; | 
					
						
							|  |  |  | 		$end = strpos ($dn, ","); | 
					
						
							|  |  |  | 		$users[] = substr($dn, $start, $end-$start); | 
					
						
							| 
									
										
										
										
											2005-03-26 11:27:15 +00:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2004-01-10 11:47:48 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	//load account
 | 
					
						
							|  |  |  | 	$_SESSION['account'] = new accountContainer($_GET['type'], 'account'); | 
					
						
							|  |  |  | 	// Show HTML Page
 | 
					
						
							| 
									
										
										
										
											2010-01-01 17:21:46 +00:00
										 |  |  | 	include 'main_header.php'; | 
					
						
							| 
									
										
										
										
											2013-01-19 13:18:52 +00:00
										 |  |  | 	echo "<div class=\"".$_GET['type']."-bright smallPaddingContent\">"; | 
					
						
							| 
									
										
										
										
											2010-08-21 09:43:52 +00:00
										 |  |  | 	echo "<br>\n"; | 
					
						
							| 
									
										
										
										
											2004-01-10 11:47:48 +00:00
										 |  |  | 	echo "<form action=\"delete.php\" method=\"post\">\n"; | 
					
						
							| 
									
										
										
										
											2015-05-15 19:16:46 +00:00
										 |  |  | 	echo '<input type="hidden" name="' . getSecurityTokenName() . '" value="' . getSecurityTokenValue() . '">'; | 
					
						
							| 
									
										
										
										
											2004-01-10 11:47:48 +00:00
										 |  |  | 	echo "<input name=\"type\" type=\"hidden\" value=\"" . $_GET['type'] . "\">\n"; | 
					
						
							| 
									
										
										
										
											2005-03-26 11:27:15 +00:00
										 |  |  | 	echo "<b>" . _("Do you really want to remove the following accounts?") . "</b>"; | 
					
						
							|  |  |  | 	echo "<br><br>\n"; | 
					
						
							| 
									
										
										
										
											2005-11-26 12:49:48 +00:00
										 |  |  | 	echo "<table border=0>\n"; | 
					
						
							| 
									
										
										
										
											2004-01-10 11:47:48 +00:00
										 |  |  | 	for ($i=0; $i<count($users); $i++) { | 
					
						
							|  |  |  | 		echo "<tr>\n"; | 
					
						
							| 
									
										
										
										
											2012-03-13 21:34:13 +00:00
										 |  |  | 		echo "<td><b>" . _("Account name:") . "</b> " . htmlspecialchars($users[$i]) . "</td>\n"; | 
					
						
							|  |  |  | 		echo "<td>  <b>" . _('DN') . ":</b> " . htmlspecialchars($_SESSION['delete_dn'][$i]) . "</td>\n"; | 
					
						
							| 
									
										
										
										
											2005-11-26 12:49:48 +00:00
										 |  |  | 		$childCount = getChildCount($_SESSION['delete_dn'][$i]); | 
					
						
							|  |  |  | 		if ($childCount > 0) { | 
					
						
							|  |  |  | 			echo "<td>  <b>" . _('Number of child entries') . ":</b> " . $childCount . "</td>\n"; | 
					
						
							|  |  |  | 		} | 
					
						
							| 
									
										
										
										
											2004-01-10 11:47:48 +00:00
										 |  |  | 		echo "</tr>\n"; | 
					
						
							| 
									
										
										
										
											2005-03-26 11:27:15 +00:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2003-09-19 10:03:00 +00:00
										 |  |  | 	echo "</table>\n"; | 
					
						
							| 
									
										
										
										
											2004-01-10 11:47:48 +00:00
										 |  |  | 	echo "<br>\n"; | 
					
						
							|  |  |  | 	// Print delete rows from modules
 | 
					
						
							|  |  |  | 	echo "<table border=0 width=\"100%\">\n<tr><td valign=\"top\" width=\"15%\" >"; | 
					
						
							| 
									
										
										
										
											2005-04-04 16:55:34 +00:00
										 |  |  | 	$modules = $_SESSION['config']->get_AccountModules($_GET['type']); | 
					
						
							| 
									
										
										
										
											2005-04-05 12:06:30 +00:00
										 |  |  | 	$values = array(); | 
					
						
							|  |  |  | 	$tabindex = 100; | 
					
						
							| 
									
										
										
										
											2005-04-04 16:55:34 +00:00
										 |  |  | 	foreach ($modules as $module) { | 
					
						
							| 
									
										
										
										
											2013-05-09 19:10:35 +00:00
										 |  |  | 		$module = moduleCache::getModule($module, $_GET['type']); | 
					
						
							| 
									
										
										
										
											2009-02-07 19:25:22 +00:00
										 |  |  | 		parseHtml(get_class($module), $module->display_html_delete(), $values, true, $tabindex, $_GET['type']); | 
					
						
							| 
									
										
										
										
											2005-03-26 11:27:15 +00:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2004-01-10 11:47:48 +00:00
										 |  |  | 	echo "</table>\n"; | 
					
						
							|  |  |  | 	echo "<br>\n"; | 
					
						
							| 
									
										
										
										
											2010-10-12 17:49:18 +00:00
										 |  |  | 	echo "<button class=\"smallPadding\" name=\"delete\" id=\"submitButton\">" . _('Delete') . "</button> \n"; | 
					
						
							|  |  |  | 	echo "<button class=\"smallPadding\" name=\"cancel\" id=\"cancelButton\">" . _('Cancel') . "</button>\n"; | 
					
						
							| 
									
										
										
										
											2004-01-10 11:47:48 +00:00
										 |  |  | 	echo "</form>\n"; | 
					
						
							| 
									
										
										
										
											2010-10-12 17:49:18 +00:00
										 |  |  | 	echo "</div>\n"; | 
					
						
							|  |  |  | 	?>
 | 
					
						
							|  |  |  | 	<script type="text/javascript" language="javascript"> | 
					
						
							|  |  |  | 	jQuery(document).ready(function() { | 
					
						
							|  |  |  | 		jQuery('#submitButton').button(); | 
					
						
							|  |  |  | 		jQuery('#cancelButton').button(); | 
					
						
							|  |  |  | 	}); | 
					
						
							|  |  |  | 	</script> | 
					
						
							|  |  |  | 	<?php | 
					
						
							| 
									
										
										
										
											2010-08-21 09:43:52 +00:00
										 |  |  | 	include 'main_footer.php'; | 
					
						
							| 
									
										
										
										
											2005-03-26 11:27:15 +00:00
										 |  |  | } | 
					
						
							| 
									
										
										
										
											2003-05-02 07:59:13 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-09-26 11:11:01 +00:00
										 |  |  | if (isset($_POST['cancel'])) { | 
					
						
							| 
									
										
										
										
											2004-01-10 11:47:48 +00:00
										 |  |  | 	if (isset($_SESSION['delete_dn'])) unset($_SESSION['delete_dn']); | 
					
						
							| 
									
										
										
										
											2006-01-06 10:47:43 +00:00
										 |  |  | 	metaRefresh("lists/list.php?type=" . $_POST['type']); | 
					
						
							| 
									
										
										
										
											2005-03-26 11:27:15 +00:00
										 |  |  | } | 
					
						
							| 
									
										
										
										
											2010-11-26 20:16:14 +00:00
										 |  |  | elseif (isset($_POST['cancelAllOk'])) { | 
					
						
							|  |  |  | 	if (isset($_SESSION['delete_dn'])) unset($_SESSION['delete_dn']); | 
					
						
							|  |  |  | 	metaRefresh("lists/list.php?type=" . $_POST['type'] . '&deleteAllOk=1'); | 
					
						
							|  |  |  | } | 
					
						
							| 
									
										
										
										
											2003-09-19 10:03:00 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-09-26 11:11:01 +00:00
										 |  |  | if (isset($_POST['delete'])) { | 
					
						
							| 
									
										
										
										
											2014-02-07 20:10:41 +00:00
										 |  |  | 	if (!checkIfDeleteEntriesIsAllowed($_POST['type']) || !checkIfWriteAccessIsAllowed($_POST['type'])) { | 
					
						
							| 
									
										
										
										
											2013-05-01 12:36:17 +00:00
										 |  |  | 		logNewMessage(LOG_ERR, 'User tried to delete entries of forbidden type '. $_POST['type']); | 
					
						
							|  |  |  | 		die(); | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2004-01-10 11:47:48 +00:00
										 |  |  | 	// Show HTML Page
 | 
					
						
							| 
									
										
										
										
											2010-01-01 17:21:46 +00:00
										 |  |  | 	include 'main_header.php'; | 
					
						
							| 
									
										
										
										
											2004-01-10 11:47:48 +00:00
										 |  |  | 	echo "<form action=\"delete.php\" method=\"post\">\n"; | 
					
						
							| 
									
										
										
										
											2015-05-15 19:16:46 +00:00
										 |  |  | 	echo '<input type="hidden" name="' . getSecurityTokenName() . '" value="' . getSecurityTokenValue() . '">'; | 
					
						
							| 
									
										
										
										
											2004-01-10 11:47:48 +00:00
										 |  |  | 	echo "<input name=\"type\" type=\"hidden\" value=\"" . $_POST['type'] . "\">\n"; | 
					
						
							| 
									
										
										
										
											2013-01-19 13:18:52 +00:00
										 |  |  | 	echo "<div class=\"".$_POST['type']."-bright smallPaddingContent\"><br>\n"; | 
					
						
							| 
									
										
										
										
											2010-10-12 17:49:18 +00:00
										 |  |  | 	echo "<br>\n"; | 
					
						
							|  |  |  | 	 | 
					
						
							| 
									
										
										
										
											2004-01-10 11:47:48 +00:00
										 |  |  | 	// Delete dns
 | 
					
						
							| 
									
										
										
										
											2010-11-26 20:16:14 +00:00
										 |  |  | 	$allOk = true; | 
					
						
							| 
									
										
										
										
											2012-06-05 18:20:17 +00:00
										 |  |  | 	$allErrors = array(); | 
					
						
							| 
									
										
										
										
											2004-01-10 11:47:48 +00:00
										 |  |  | 	for ($m=0; $m<count($_SESSION['delete_dn']); $m++) { | 
					
						
							|  |  |  | 		// Set to true if an real error has happened
 | 
					
						
							|  |  |  | 		$stopprocessing = false; | 
					
						
							|  |  |  | 		// First load DN.
 | 
					
						
							|  |  |  | 		$_SESSION['account']->load_account($_SESSION['delete_dn'][$m]); | 
					
						
							|  |  |  | 		// get commands and changes of each attribute
 | 
					
						
							| 
									
										
										
										
											2007-10-26 14:10:10 +00:00
										 |  |  | 		$moduleNames = array_keys($_SESSION['account']->getAccountModules()); | 
					
						
							|  |  |  | 		$modules = $_SESSION['account']->getAccountModules(); | 
					
						
							| 
									
										
										
										
											2004-01-10 11:47:48 +00:00
										 |  |  | 		$attributes = array(); | 
					
						
							|  |  |  | 		$errors = array(); | 
					
						
							| 
									
										
										
										
											2007-02-25 13:51:40 +00:00
										 |  |  | 		// predelete actions
 | 
					
						
							|  |  |  | 		if (!$stopprocessing) { | 
					
						
							| 
									
										
										
										
											2007-10-26 14:10:10 +00:00
										 |  |  | 			foreach ($moduleNames as $singlemodule) { | 
					
						
							| 
									
										
										
										
											2010-11-26 20:16:14 +00:00
										 |  |  | 				$success = true; | 
					
						
							|  |  |  | 				$messages = $modules[$singlemodule]->preDeleteActions(); | 
					
						
							|  |  |  | 				for ($i = 0; $i < sizeof($messages); $i++) { | 
					
						
							|  |  |  | 					$errors[] = $messages[$i]; | 
					
						
							|  |  |  | 					if ($messages[$i][0] == 'ERROR') { | 
					
						
							|  |  |  | 						$success = false; | 
					
						
							|  |  |  | 						$allOk = false; | 
					
						
							|  |  |  | 					} | 
					
						
							|  |  |  | 					elseif ($messages[$i][0] == 'WARN') { | 
					
						
							|  |  |  | 						$allOk = false; | 
					
						
							|  |  |  | 					} | 
					
						
							|  |  |  | 				} | 
					
						
							| 
									
										
										
										
											2007-02-25 13:51:40 +00:00
										 |  |  | 				if (!$success) { | 
					
						
							|  |  |  | 					$stopprocessing = true; | 
					
						
							|  |  |  | 					break; | 
					
						
							| 
									
										
										
										
											2004-01-10 11:47:48 +00:00
										 |  |  | 				} | 
					
						
							|  |  |  | 			} | 
					
						
							| 
									
										
										
										
											2009-06-14 12:31:51 +00:00
										 |  |  | 		} | 
					
						
							| 
									
										
										
										
											2007-02-25 13:51:40 +00:00
										 |  |  | 		if (!$stopprocessing) { | 
					
						
							|  |  |  | 			// load attributes
 | 
					
						
							| 
									
										
										
										
											2007-10-26 14:10:10 +00:00
										 |  |  | 			foreach ($moduleNames as $singlemodule) { | 
					
						
							| 
									
										
										
										
											2007-02-25 13:51:40 +00:00
										 |  |  | 				// load changes
 | 
					
						
							| 
									
										
										
										
											2007-10-26 14:10:10 +00:00
										 |  |  | 				$temp = $modules[$singlemodule]->delete_attributes(); | 
					
						
							| 
									
										
										
										
											2007-02-25 13:51:40 +00:00
										 |  |  | 				if (is_array($temp)) { | 
					
						
							|  |  |  | 					// merge changes
 | 
					
						
							|  |  |  | 					$DNs = array_keys($temp); | 
					
						
							|  |  |  | 					$attributes = array_merge_recursive($temp, $attributes); | 
					
						
							|  |  |  | 					for ($i=0; $i<count($DNs); $i++) { | 
					
						
							|  |  |  | 						$ops = array_keys($temp[$DNs[$i]]); | 
					
						
							|  |  |  | 						for ($j=0; $j<count($ops); $j++) { | 
					
						
							|  |  |  | 							$attrs = array_keys($temp[$DNs[$i]][$ops[$j]]); | 
					
						
							|  |  |  | 							for ($k=0; $k<count($attrs); $k++) | 
					
						
							|  |  |  | 							$attributes[$DNs[$i]][$ops[$j]][$attrs[$k]] = array_unique($attributes[$DNs[$i]][$ops[$j]][$attrs[$k]]); | 
					
						
							|  |  |  | 						} | 
					
						
							|  |  |  | 					} | 
					
						
							| 
									
										
										
										
											2004-01-10 11:47:48 +00:00
										 |  |  | 				} | 
					
						
							| 
									
										
										
										
											2005-03-26 11:27:15 +00:00
										 |  |  | 			} | 
					
						
							| 
									
										
										
										
											2007-02-25 13:51:40 +00:00
										 |  |  | 			$DNs = array_keys($attributes); | 
					
						
							|  |  |  | 			for ($i=0; $i<count($DNs); $i++) { | 
					
						
							|  |  |  | 				if (isset($attributes[$DNs[$i]]['errors'])) { | 
					
						
							|  |  |  | 					foreach ($attributes[$DNs[$i]]['errors'] as $singleerror) { | 
					
						
							|  |  |  | 						$errors[] = $singleerror; | 
					
						
							| 
									
										
										
										
											2010-11-26 20:16:14 +00:00
										 |  |  | 						if ($singleerror[0] == 'ERROR') { | 
					
						
							|  |  |  | 							$stopprocessing = true; | 
					
						
							|  |  |  | 							$allOk = false; | 
					
						
							|  |  |  | 						} | 
					
						
							| 
									
										
										
										
											2003-05-15 20:59:26 +00:00
										 |  |  | 					} | 
					
						
							| 
									
										
										
										
											2005-03-26 11:27:15 +00:00
										 |  |  | 				} | 
					
						
							| 
									
										
										
										
											2007-02-25 13:51:40 +00:00
										 |  |  | 				if (!$stopprocessing) { | 
					
						
							|  |  |  | 					// modify attributes
 | 
					
						
							|  |  |  | 					if (isset($attributes[$DNs[$i]]['modify']) && !$stopprocessing) { | 
					
						
							|  |  |  | 						$success = @ldap_mod_replace($_SESSION['ldap']->server(), $DNs[$i], $attributes[$DNs[$i]]['modify']); | 
					
						
							|  |  |  | 						if (!$success) { | 
					
						
							| 
									
										
										
										
											2013-10-16 17:37:17 +00:00
										 |  |  | 							$errors[] = array ('ERROR', sprintf(_('Was unable to modify attributes from DN: %s.'), $DNs[$i]), getDefaultLDAPErrorString($_SESSION['ldap']->server())); | 
					
						
							| 
									
										
										
										
											2007-02-25 13:51:40 +00:00
										 |  |  | 							$stopprocessing = true; | 
					
						
							| 
									
										
										
										
											2010-11-26 20:16:14 +00:00
										 |  |  | 							$allOk = false; | 
					
						
							| 
									
										
										
										
											2007-02-25 13:51:40 +00:00
										 |  |  | 						} | 
					
						
							| 
									
										
										
										
											2003-04-26 21:58:00 +00:00
										 |  |  | 					} | 
					
						
							| 
									
										
										
										
											2007-02-25 13:51:40 +00:00
										 |  |  | 					// add attributes
 | 
					
						
							|  |  |  | 					if (isset($attributes[$DNs[$i]]['add']) && !$stopprocessing) { | 
					
						
							|  |  |  | 						$success = @ldap_mod_add($_SESSION['ldap']->server(), $DNs[$i], $attributes[$DNs[$i]]['add']); | 
					
						
							|  |  |  | 						if (!$success) { | 
					
						
							| 
									
										
										
										
											2013-10-16 17:37:17 +00:00
										 |  |  | 							$errors[] = array ('ERROR', sprintf(_('Was unable to add attributes to DN: %s.'), $DNs[$i]), getDefaultLDAPErrorString($_SESSION['ldap']->server())); | 
					
						
							| 
									
										
										
										
											2007-02-25 13:51:40 +00:00
										 |  |  | 							$stopprocessing = true; | 
					
						
							| 
									
										
										
										
											2010-11-26 20:16:14 +00:00
										 |  |  | 							$allOk = false; | 
					
						
							| 
									
										
										
										
											2007-02-25 13:51:40 +00:00
										 |  |  | 						} | 
					
						
							|  |  |  | 					} | 
					
						
							| 
									
										
										
										
											2011-02-26 13:14:10 +00:00
										 |  |  | 					// remove attributes
 | 
					
						
							| 
									
										
										
										
											2007-02-25 13:51:40 +00:00
										 |  |  | 					if (isset($attributes[$DNs[$i]]['remove']) && !$stopprocessing) { | 
					
						
							|  |  |  | 						$success = @ldap_mod_del($_SESSION['ldap']->server(), $DNs[$i], $attributes[$DNs[$i]]['remove']); | 
					
						
							|  |  |  | 						if (!$success) { | 
					
						
							| 
									
										
										
										
											2013-10-16 17:37:17 +00:00
										 |  |  | 							$errors[] = array ('ERROR', sprintf(_('Was unable to remove attributes from DN: %s.'), $DNs[$i]), getDefaultLDAPErrorString($_SESSION['ldap']->server())); | 
					
						
							| 
									
										
										
										
											2007-02-25 13:51:40 +00:00
										 |  |  | 							$stopprocessing = true; | 
					
						
							| 
									
										
										
										
											2010-11-26 20:16:14 +00:00
										 |  |  | 							$allOk = false; | 
					
						
							| 
									
										
										
										
											2007-02-25 13:51:40 +00:00
										 |  |  | 						} | 
					
						
							| 
									
										
										
										
											2004-01-10 11:47:48 +00:00
										 |  |  | 					} | 
					
						
							|  |  |  | 				} | 
					
						
							|  |  |  | 			} | 
					
						
							| 
									
										
										
										
											2005-03-26 11:27:15 +00:00
										 |  |  | 		} | 
					
						
							| 
									
										
										
										
											2004-01-10 11:47:48 +00:00
										 |  |  | 		if (!$stopprocessing) { | 
					
						
							| 
									
										
										
										
											2012-06-05 18:20:17 +00:00
										 |  |  | 			$messages = deleteDN($_SESSION['delete_dn'][$m]); | 
					
						
							|  |  |  | 			$errors = array_merge($errors, $messages); | 
					
						
							| 
									
										
										
										
											2010-11-26 20:16:14 +00:00
										 |  |  | 			if (sizeof($errors) > 0) { | 
					
						
							|  |  |  | 				$stopprocessing = true; | 
					
						
							|  |  |  | 				$allOk = false; | 
					
						
							|  |  |  | 			} | 
					
						
							| 
									
										
										
										
											2005-03-26 11:27:15 +00:00
										 |  |  | 		} | 
					
						
							| 
									
										
										
										
											2007-02-25 13:51:40 +00:00
										 |  |  | 		// post delete actions
 | 
					
						
							| 
									
										
										
										
											2007-02-22 18:26:23 +00:00
										 |  |  | 		if (!$stopprocessing) { | 
					
						
							| 
									
										
										
										
											2007-10-26 14:10:10 +00:00
										 |  |  | 			foreach ($moduleNames as $singlemodule) { | 
					
						
							| 
									
										
										
										
											2010-11-26 20:16:14 +00:00
										 |  |  | 				$messages = $modules[$singlemodule]->postDeleteActions(); | 
					
						
							|  |  |  | 				for ($i = 0; $i < sizeof($messages); $i++) { | 
					
						
							|  |  |  | 					$errors[] = $messages[$i]; | 
					
						
							|  |  |  | 					if (($messages[$i][0] == 'ERROR') || ($messages[$i][0] == 'WARN')) { | 
					
						
							|  |  |  | 						$allOk = false; | 
					
						
							|  |  |  | 					} | 
					
						
							|  |  |  | 				} | 
					
						
							| 
									
										
										
										
											2007-02-22 18:26:23 +00:00
										 |  |  | 			} | 
					
						
							|  |  |  | 		}		 | 
					
						
							| 
									
										
										
										
											2004-01-10 11:47:48 +00:00
										 |  |  | 		if (!$stopprocessing) { | 
					
						
							| 
									
										
										
										
											2005-03-26 11:27:15 +00:00
										 |  |  | 			echo sprintf(_('Deleted DN: %s'), $_SESSION['delete_dn'][$m]) . "<br>\n"; | 
					
						
							| 
									
										
										
										
											2010-11-26 20:16:14 +00:00
										 |  |  | 			foreach ($errors as $error) { | 
					
						
							|  |  |  | 				call_user_func_array('StatusMessage', $error); | 
					
						
							|  |  |  | 			} | 
					
						
							| 
									
										
										
										
											2005-03-26 11:27:15 +00:00
										 |  |  | 			echo "<br>\n"; | 
					
						
							| 
									
										
										
										
											2010-10-12 17:49:18 +00:00
										 |  |  | 			flush(); | 
					
						
							| 
									
										
										
										
											2005-03-26 11:27:15 +00:00
										 |  |  | 		} | 
					
						
							| 
									
										
										
										
											2004-01-10 11:47:48 +00:00
										 |  |  | 		else { | 
					
						
							| 
									
										
										
										
											2005-03-26 11:27:15 +00:00
										 |  |  | 			echo sprintf(_('Error while deleting DN: %s'), $_SESSION['delete_dn'][$m]) . "<br>\n"; | 
					
						
							| 
									
										
										
										
											2010-11-26 20:16:14 +00:00
										 |  |  | 			foreach ($errors as $error) { | 
					
						
							|  |  |  | 				call_user_func_array('StatusMessage', $error); | 
					
						
							|  |  |  | 			} | 
					
						
							| 
									
										
										
										
											2005-03-26 11:27:15 +00:00
										 |  |  | 			echo "<br>\n"; | 
					
						
							| 
									
										
										
										
											2003-08-20 19:16:03 +00:00
										 |  |  | 		} | 
					
						
							| 
									
										
										
										
											2012-06-05 18:20:17 +00:00
										 |  |  | 		$allErrors = array_merge($allErrors, $errors); | 
					
						
							| 
									
										
										
										
											2005-03-26 11:27:15 +00:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2004-01-10 11:47:48 +00:00
										 |  |  | 	echo "<br>\n"; | 
					
						
							| 
									
										
										
										
											2010-10-12 17:49:18 +00:00
										 |  |  | 	echo "<br><button class=\"smallPadding\" name=\"cancel\" id=\"backButton\">" . _('Back to list') . "</button>\n"; | 
					
						
							| 
									
										
										
										
											2010-11-26 20:16:14 +00:00
										 |  |  | 	echo "<br><button class=\"hidden\" name=\"cancelAllOk\" id=\"backButtonAllOk\"> </button>\n"; | 
					
						
							| 
									
										
										
										
											2010-10-12 17:49:18 +00:00
										 |  |  | 	echo "</div>\n"; | 
					
						
							| 
									
										
										
										
											2004-01-10 11:47:48 +00:00
										 |  |  | 	echo "</form>\n"; | 
					
						
							| 
									
										
										
										
											2010-10-12 17:49:18 +00:00
										 |  |  | 	?>
 | 
					
						
							|  |  |  | 	<script type="text/javascript" language="javascript"> | 
					
						
							|  |  |  | 	jQuery(document).ready(function() { | 
					
						
							|  |  |  | 		jQuery('#backButton').button(); | 
					
						
							| 
									
										
										
										
											2010-11-26 20:16:14 +00:00
										 |  |  | 		<?php | 
					
						
							|  |  |  | 		if ($allOk) { | 
					
						
							| 
									
										
										
										
											2012-06-05 18:20:17 +00:00
										 |  |  | 			$_SESSION['listRedirectMessages'] = $allErrors; | 
					
						
							| 
									
										
										
										
											2010-11-26 20:16:14 +00:00
										 |  |  | 			echo "jQuery('#backButtonAllOk').click();"; | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 		?>
 | 
					
						
							| 
									
										
										
										
											2010-10-12 17:49:18 +00:00
										 |  |  | 	}); | 
					
						
							|  |  |  | 	</script> | 
					
						
							|  |  |  | 	<?php | 
					
						
							| 
									
										
										
										
											2010-08-21 09:43:52 +00:00
										 |  |  | 	include 'main_footer.php'; | 
					
						
							| 
									
										
										
										
											2003-05-02 07:59:13 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2005-03-26 11:27:15 +00:00
										 |  |  | } | 
					
						
							| 
									
										
										
										
											2003-05-02 07:59:13 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2005-11-26 12:49:48 +00:00
										 |  |  | /** | 
					
						
							|  |  |  | * Returns the number of child entries of a DN. | 
					
						
							|  |  |  | * | 
					
						
							|  |  |  | * @param string $dn DN of parent | 
					
						
							|  |  |  | * @return interger number of childs | 
					
						
							|  |  |  | */ | 
					
						
							|  |  |  | function getChildCount($dn) { | 
					
						
							| 
									
										
										
										
											2010-02-07 14:04:29 +00:00
										 |  |  | 	$entries = searchLDAP(escapeDN($dn), 'objectClass=*', array('dn')); | 
					
						
							|  |  |  | 	return (sizeof($entries) - 1); | 
					
						
							| 
									
										
										
										
											2005-11-26 12:49:48 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /** | 
					
						
							|  |  |  | * Deletes a DN and all child entries. | 
					
						
							| 
									
										
										
										
											2006-08-14 17:29:45 +00:00
										 |  |  | * | 
					
						
							| 
									
										
										
										
											2005-11-26 12:49:48 +00:00
										 |  |  | * @param string $dn DN to delete | 
					
						
							|  |  |  | * @return array error messages | 
					
						
							|  |  |  | */ | 
					
						
							|  |  |  | function deleteDN($dn) { | 
					
						
							|  |  |  | 	$errors = array(); | 
					
						
							| 
									
										
										
										
											2011-09-27 18:21:37 +00:00
										 |  |  | 	if (($dn == null) || ($dn == '')) { | 
					
						
							|  |  |  | 		$errors[] = array('ERROR', _('Entry does not exist')); | 
					
						
							|  |  |  | 		return $errors; | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2010-02-15 17:36:45 +00:00
										 |  |  | 	$sr = @ldap_list($_SESSION['ldap']->server(), $dn, 'objectClass=*', array('dn'), 0, 0, 0, LDAP_DEREF_NEVER); | 
					
						
							| 
									
										
										
										
											2005-11-26 12:49:48 +00:00
										 |  |  | 	if ($sr) { | 
					
						
							| 
									
										
										
										
											2007-07-08 10:51:01 +00:00
										 |  |  | 		$entries = ldap_get_entries($_SESSION['ldap']->server(), $sr); | 
					
						
							| 
									
										
										
										
											2011-05-21 10:58:22 +00:00
										 |  |  | 		cleanLDAPResult($entries); | 
					
						
							| 
									
										
										
										
											2009-12-19 16:28:16 +00:00
										 |  |  | 		for ($i = 0; $i < sizeof($entries); $i++) { | 
					
						
							| 
									
										
										
										
											2005-11-26 12:49:48 +00:00
										 |  |  | 			// delete recursively
 | 
					
						
							|  |  |  | 			$subErrors = deleteDN($entries[$i]['dn']); | 
					
						
							|  |  |  | 			for ($e = 0; $e < sizeof($subErrors); $e++) $errors[] = $subErrors[$e]; | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 	else { | 
					
						
							| 
									
										
										
										
											2013-10-16 17:37:17 +00:00
										 |  |  | 		$errors[] = array ('ERROR', sprintf(_('Was unable to delete DN: %s.'), $dn), getDefaultLDAPErrorString($_SESSION['ldap']->server())); | 
					
						
							| 
									
										
										
										
											2010-10-12 17:49:18 +00:00
										 |  |  | 		return $errors; | 
					
						
							| 
									
										
										
										
											2005-11-26 12:49:48 +00:00
										 |  |  | 	} | 
					
						
							|  |  |  | 	// delete parent DN
 | 
					
						
							|  |  |  | 	$success = @ldap_delete($_SESSION['ldap']->server(), $dn); | 
					
						
							| 
									
										
										
										
											2006-05-16 15:18:24 +00:00
										 |  |  | 	$ldapUser = $_SESSION['ldap']->decrypt_login(); | 
					
						
							|  |  |  | 	$ldapUser = $ldapUser[0]; | 
					
						
							| 
									
										
										
										
											2005-11-26 12:49:48 +00:00
										 |  |  | 	if (!$success) { | 
					
						
							| 
									
										
										
										
											2013-10-16 17:37:17 +00:00
										 |  |  | 		logNewMessage(LOG_ERR, '[' . $ldapUser .'] Unable to delete DN: ' . $dn . ' (' . ldap_error($_SESSION['ldap']->server()) . ').'); | 
					
						
							|  |  |  | 		$errors[] = array ('ERROR', sprintf(_('Was unable to delete DN: %s.'), $dn), getDefaultLDAPErrorString($_SESSION['ldap']->server())); | 
					
						
							| 
									
										
										
										
											2005-11-26 12:49:48 +00:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2006-05-16 15:18:24 +00:00
										 |  |  | 	else { | 
					
						
							|  |  |  | 		logNewMessage(LOG_NOTICE, '[' . $ldapUser .'] Deleted DN: ' . $dn); | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2005-11-26 12:49:48 +00:00
										 |  |  | 	return $errors; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2003-04-25 16:14:09 +00:00
										 |  |  | ?>
 |