phpldapadmin/htdocs/delete_attr.php

55 lines
1.5 KiB
PHP
Raw Normal View History

2009-06-30 09:22:30 +00:00
<?php
2009-06-30 10:40:03 +00:00
// $Header: /cvsroot/phpldapadmin/phpldapadmin/htdocs/delete_attr.php,v 1.15 2005/12/10 10:34:54 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 09:29:51 +00:00
* Variables that come in via common.php
* - server_id
*
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
if (! $ldapserver->haveAuthInfo())
2009-06-30 10:26:08 +00:00
pla_error(_('Not enough information to login to server. Please check your configuration.'));
2009-06-30 09:29:51 +00:00
$dn = isset($_POST['dn']) ? $_POST['dn'] : null;
$attr = isset($_POST['attr']) ? $_POST['attr'] : null;
if (! $dn)
2009-06-30 10:26:08 +00:00
pla_error(_('No DN specified'));
2009-06-30 09:29:51 +00:00
if (! $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 09:29:51 +00:00
$encoded_dn = rawurlencode($dn);
2009-06-30 08:07:14 +00:00
2009-06-30 10:26:08 +00:00
if ($ldapserver->isAttrReadOnly($attr))
pla_error(sprintf(_('The attribute "%s" is flagged as read-only in the phpLDAPadmin configuration.'),htmlspecialchars($attr)));
2009-06-30 08:07:14 +00:00
$update_array = array();
$update_array[$attr] = array();
2009-06-30 09:29:51 +00:00
2009-06-30 10:26:08 +00:00
$res = $ldapserver->modify($dn,$update_array);
2009-06-30 09:29:51 +00:00
if ($res) {
2009-06-30 10:26:08 +00:00
$redirect_url = sprintf('template_engine.php?server_id=%s&dn=%s',$ldapserver->server_id,$encoded_dn);
2009-06-30 09:29:51 +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");
} 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
?>