phpldapadmin/htdocs/delete_attr.php

55 lines
1.3 KiB
PHP
Raw Normal View History

2009-06-30 09:22:30 +00:00
<?php
2009-06-30 09:29:51 +00:00
// $Header: /cvsroot/phpldapadmin/phpldapadmin/delete_attr.php,v 1.13 2005/09/17 20:04:29 wurley Exp $
2009-06-30 09:22:30 +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 08:07:14 +00:00
* On success, redirect to edit.php
* 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())
pla_error($lang['no_updates_in_read_only_mode']);
if (! $ldapserver->haveAuthInfo())
pla_error($lang['not_enough_login_info']);
$dn = isset($_POST['dn']) ? $_POST['dn'] : null;
$attr = isset($_POST['attr']) ? $_POST['attr'] : null;
if (! $dn)
pla_error($lang['no_dn_specified']);
if (! $attr)
pla_error($lang['no_attr_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 09:29:51 +00:00
if (is_attr_read_only($ldapserver,$attr))
pla_error(sprintf($lang['attr_is_read_only'],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
$res = @ldap_modify($ldapserver->connect(),$dn,$update_array);
if ($res) {
$redirect_url = sprintf("edit.php?server_id=%s&dn=%s",$ldapserver->server_id,$encoded_dn);
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 {
pla_error($lang['could_not_perform_ldap_modify'],ldap_error($ldapserver->connect()),ldap_errno($ldapserver->connect()));
}
2009-06-30 08:07:14 +00:00
?>