'; echo _('Delete Account'); echo ''."\n". ''."\n". ''."\n". ''."\n". '
'."\n"; if ($_GET['type']) { // $_GET['type'] is true if delete.php was called from *list.php // Store $_GET['type'] as $_POST['type'] // Replace wrong chars from Session echo ''; switch ($_GET['type']) { // Select which layout and text should be displayed case 'user': echo "
"; echo _('Delete user(s)'); echo "\n"; echo ''._('Do you really want to delete user(s):').''; break; case 'host': echo "
"; echo _('Delete host(s)'); echo "\n"; echo ''._('Do you really want to delete host(s):').''; break; case 'group': echo "
"; echo _('Delete group(s)'); echo "\n"; echo ''._('Do you really want to delete group(s):').''; break; } echo "
\n"; // display all DNs in a tables echo "\n"; foreach ($delete_dn as $dn) echo ''; echo "
'.$dn.'
\n"; // Ask if lam should delete homedirs if users are deleted and lamdaemon.pl is in use if (($_GET['type']== user) && $config_intern->scriptServer) { echo "
\n"; echo "\n"; echo ''."\n".''."\n"; echo "
'; echo _('Delete also Homedirectories'); echo ''. '
\n"; } // Print buttons echo "
\n"; echo ''; echo ' '; echo "
\n"; } if ($_POST['delete_yes']) { // deletion has been confirmed. switch ($_POST['type']) { case 'user': echo "
"; echo _('Deleting user(s)...'); echo "\n"; break; case 'host': echo "
"; echo _('Deleting host(s)...'); echo "\n"; break; case 'group': echo "
"; echo _('Deleting group(s)...'); echo "\n"; break; } // Store kind of DNs echo ''; echo "
\n"; // Loop for every DN which should be deleted foreach ($delete_dn as $dn) { switch ($_POST['type']) { case 'user': // Get username from DN $temp=explode(',', $dn); $username = str_replace('uid=', '', $temp[0]); // Fill array with groupnames $usernames[] = $username; // Search for groups which have memberUid set to username $result = ldap_search($ldap_intern->server(), $config_intern->get_GroupSuffix(), "(&(objectClass=PosixGroup)(memberUid=$username))", array('')); $entry = ldap_first_entry($ldap_intern->server(), $result); // loop for every found group and remove membership while ($entry) { $success = ldap_mod_del($ldap_intern->server(), ldap_get_dn($ldap_intern->server(), $entry) , array('memberUid' => $username)); // *** fixme add error-message if memberUid couldn't be deleted $entry = ldap_next_entry($ldap_intern->server(), $entry); } if ($config_intern->scriptServer && isset($username)) { // Remove homedir if required if ($_POST['f_rem_home']) remhomedir($username); // Remove quotas if lamdaemon.pl is used remquotas($username, 'user'); } // Delete user itself $success = ldap_delete($ldap_intern->server(), $dn); if (!$success) $error = _('Could not delete user:').' '.$dn; break; case 'host': // Delete host itself $success = ldap_delete($ldap_intern->server(), $dn); if (!$success) $error = _('Could not delete host:').' '.$dn; break; case 'group': /* First we have to check if any user uses $group * as primary group. It's not allowed to delete a * group if it still contains primaty members */ $temp=explode(',', $dn); $groupname = str_replace('cn=', '', $temp[0]); // Fill array with groupnames $usernames[] = $groupname; // Get group GIDNumber $groupgid = getgid($groupname); // Search for users which have gid set to current gid $result = ldap_search($ldap_intern->server(), $config_intern->get_UserSuffix(), "gidNumber=$groupgid", array('')); // Print error if still users in group if (!$result) $error = _('Could not delete group. Still users in group:').' '.$dn; else { // Remove quotas if lamdaemon.pl is used if ($config_intern->scriptServer && isset($groupname)) { remquotas($groupname, 'group'); } // Delete group itself $success = ldap_delete($ldap_intern->server(), $dn); if (!$success) $error = _('Could not delete group:').' '.$dn; } break; } // Remove DNs from cache-array if ($success && isset($_SESSION[$_POST['type'].'DN'][$dn])) unset($_SESSION[$_POST['type'].'DN'][$dn]); // Display success or error-message if (!$error) echo "\n"; else echo "\n"; } echo "
$dn ". _('deleted').".
$error

\n"; switch ($_POST['type']) { // Select which page should be displayd if back-button will be pressed case 'user': echo ''; break; case 'group': echo ''; break; case 'host': echo ''; break; } echo "
\n"; } if ($_POST['delete_no']) { // Delete no accounts echo ''; switch ($_POST['type']) { // Select which page should be displayd if back-button will be pressed case 'user': echo "
"; echo _('Deleting user(s) canceled.'); echo "\n"; echo _('No user(s) were deleted'); echo "
"; echo ''; break; case 'host': echo "
"; echo _('Deleting host(s) canceled.'); echo "\n"; echo _('No host(s) were deleted'); echo "
"; echo ''; break; case 'group': echo "
"; echo _('Deleting group(s) canceled.'); echo "\n"; echo _('No group(s) were deleted'); echo "
"; echo ''; break; } echo "
\n"; } echo ''."\n"; ?>