phpldapadmin/htdocs/delete_attr.php

53 lines
1.6 KiB
PHP
Raw Normal View History

2009-06-30 09:22:30 +00:00
<?php
2009-06-30 10:46:00 +00:00
// $Header: /cvsroot/phpldapadmin/phpldapadmin/htdocs/delete_attr.php,v 1.16 2007/12/15 07:50:30 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 10:26:08 +00:00
pla_error(_('You cannot perform updates while server is in read-only mode'));
2009-06-30 09:29:51 +00:00
2009-06-30 10:46:00 +00:00
if (! $_SESSION['plaConfig']->isCommandAvailable('attribute_delete'))
pla_error(sprintf('%s%s %s',_('This operation is not permitted by the configuration'),_(':'),_('delete attribute')));
$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 10:26:08 +00:00
pla_error(_('No DN specified'));
2009-06-30 09:29:51 +00:00
2009-06-30 10:46:00 +00:00
if (! $entry['attr'])
2009-06-30 10:26:08 +00:00
pla_error(_('No attribute name specified.'));
2009-06-30 08:09:20 +00:00
2009-06-30 10:46:00 +00:00
if ($ldapserver->isAttrReadOnly($entry['attr']))
pla_error(sprintf(_('The attribute "%s" is flagged as read-only in the phpLDAPadmin configuration.'),htmlspecialchars($entry['attr'])));
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 10:26:08 +00:00
pla_error(_('Could not perform ldap_modify operation.'),$ldapserver->error(),$ldapserver->errno());
2009-06-30 09:29:51 +00:00
}
2009-06-30 08:07:14 +00:00
?>