phpldapadmin/htdocs/delete_attr.php

57 lines
1.8 KiB
PHP
Raw Normal View History

2009-06-30 09:22:30 +00:00
<?php
2009-06-30 11:52:55 +00:00
// $Header: /cvsroot/phpldapadmin/phpldapadmin/htdocs/delete_attr.php,v 1.16.2.2 2008/12/12 12:20:22 wurley Exp $
2009-06-30 10:26:08 +00:00
2009-06-30 09:29:51 +00:00
/**
2009-06-30 08:07:14 +00:00
* Deletes an attribute from an entry with NO confirmation.
*
2009-06-30 10:26:08 +00:00
* On success, redirect to template_engine.php
2009-06-30 08:07:14 +00:00
* On failure, echo an error.
2009-06-30 09:29:51 +00:00
*
* @package phpLDAPadmin
*/
/**
2009-06-30 08:07:14 +00:00
*/
2009-06-30 09:22:30 +00:00
require './common.php';
2009-06-30 08:07:14 +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 09:29:51 +00:00
2009-06-30 11:46:44 +00:00
if (! $_SESSION[APPCONFIG]->isCommandAvailable('attribute_delete'))
2009-06-30 11:52:55 +00:00
error(sprintf('%s%s %s',_('This operation is not permitted by the configuration'),_(':'),_('delete attribute')),'error','index.php');
2009-06-30 10:46:00 +00:00
2009-06-30 11:52:55 +00:00
$entry = array();
2009-06-30 10:46:00 +00:00
$entry['dn']['string'] = get_request('dn');
$entry['dn']['encode'] = rawurlencode($entry['dn']['string']);
$entry['attr'] = get_request('attr');
2009-06-30 09:29:51 +00:00
2009-06-30 10:46:00 +00:00
if (! $entry['dn']['string'])
2009-06-30 11:52:55 +00:00
error(_('No DN specified'),'error','index.php');
2009-06-30 09:29:51 +00:00
2009-06-30 10:46:00 +00:00
if (! $entry['attr'])
2009-06-30 11:52:55 +00:00
error(_('No attribute name specified.'),'error','index.php');
2009-06-30 08:09:20 +00:00
2009-06-30 10:46:00 +00:00
if ($ldapserver->isAttrReadOnly($entry['attr']))
2009-06-30 11:52:55 +00:00
error(sprintf(_('The attribute "%s" is flagged as read-only in the phpLDAPadmin configuration.'),htmlspecialchars($entry['attr'])),'error','index.php');
2009-06-30 08:07:14 +00:00
$update_array = array();
2009-06-30 10:46:00 +00:00
$update_array[$entry['attr']] = array();
2009-06-30 09:29:51 +00:00
2009-06-30 10:46:00 +00:00
$result = $ldapserver->modify($entry['dn']['string'],$update_array);
if ($result) {
$redirect_url = sprintf('cmd.php?cmd=template_engine&server_id=%s&dn=%s',$ldapserver->server_id,$entry['dn']['encode']);
2009-06-30 09:29:51 +00:00
2009-06-30 10:46:00 +00:00
foreach ($update_array as $attr => $junk)
2009-06-30 08:07:14 +00:00
$redirect_url .= "&modified_attrs[]=$attr";
2009-06-30 09:29:51 +00:00
header("Location: $redirect_url");
2009-06-30 10:46:00 +00:00
die();
2009-06-30 09:29:51 +00:00
} else {
2009-06-30 11:52:55 +00:00
system_message(array(
'title'=>_('Could not perform ldap_modify operation.'),
'body'=>ldap_error_msg($ldapserver->error(),$ldapserver->errno()),
'type'=>'error'));
2009-06-30 09:29:51 +00:00
}
2009-06-30 08:07:14 +00:00
?>