phpldapadmin/htdocs/update.php

76 lines
2.3 KiB
PHP
Raw Permalink Normal View History

2009-06-30 09:22:30 +00:00
<?php
2009-06-30 09:29:51 +00:00
/**
2009-06-30 10:26:08 +00:00
* Updates or deletes a value from a specified attribute for a specified dn.
2009-06-30 09:29:51 +00:00
*
* @package phpLDAPadmin
* @subpackage Page
* @see update_confirm.php
2009-06-30 09:29:51 +00:00
*/
2009-06-30 09:29:51 +00:00
/**
2009-06-30 08:05:37 +00:00
*/
2009-06-30 09:29:51 +00:00
require './common.php';
2009-06-30 08:07:14 +00:00
$request = array();
$request['dn'] = get_request('dn','REQUEST',true);
2009-06-30 10:26:08 +00:00
# If cancel was submited, got back to the edit display.
2009-06-30 11:52:55 +00:00
if (get_request('cancel','REQUEST')) {
header(sprintf('Location: cmd.php?cmd=template_engine&server_id=%s&dn=%s',
$app['server']->getIndex(),rawurlencode($request['dn'])));
2009-06-30 10:40:03 +00:00
die();
2009-06-30 10:46:00 +00:00
}
2009-06-30 09:29:51 +00:00
if (! $request['dn'] || ! $app['server']->dnExists($request['dn']))
error(sprintf(_('The entry (%s) does not exist.'),$request['dn']),'error','index.php');
2009-06-30 09:29:51 +00:00
$request['page'] = new PageRender($app['server']->getIndex(),get_request('template','REQUEST',false,'none'));
$request['page']->setDN($request['dn']);
$request['page']->accept();
$request['template'] = $request['page']->getTemplate();
2009-06-30 08:05:37 +00:00
2009-06-30 10:26:08 +00:00
# Perform the modification
$result = $app['server']->modify($request['dn'],$request['template']->getLDAPmodify());
2009-06-30 10:46:00 +00:00
if ($result) {
2009-06-30 10:26:08 +00:00
# Fire the post modification event to the user's custom callback function.
$mustRelogin = false;
2009-06-30 08:09:20 +00:00
foreach ($request['template']->getLDAPmodify() as $attr_name => $val) {
2009-06-30 10:26:08 +00:00
/* Was this a user's password modification who is currently
2009-06-30 10:46:00 +00:00
* logged in? If so, they need to logout and log back in
* with the new password. */
if (($attr_name == 'userpassword') &&
in_array($app['server']->getValue('login','auth_type'),array('cookie','session')) &&
pla_compare_dns($app['server']->getLogin(),$request['dn']) === 0)
2009-06-30 10:26:08 +00:00
$mustRelogin = true;
}
2009-06-30 08:09:20 +00:00
2009-06-30 10:26:08 +00:00
# If the user password was changed, not tell the to relogin.
if ($mustRelogin) {
$app['server']->logout('user');
unset($_SESSION['ACTIVITY'][$app['server']->getIndex()]);
system_message(array(
'title'=>_('Modification successful!'),
'body'=>_('Since you changed your password, you must now login again with your new password.'),
'type'=>'info'),
sprintf('cmd.php?cmd=login_form&server_id=%s',$app['server']->getIndex()));
exit;
2009-06-30 08:09:20 +00:00
}
$redirect_url = sprintf('cmd.php?cmd=template_engine&server_id=%s&dn=%s',
$app['server']->getIndex(),rawurlencode($request['dn']));
2009-06-30 08:05:37 +00:00
foreach ($request['template']->getLDAPmodify() as $attr => $junk)
$redirect_url .= sprintf('&modified_attrs[]=%s',$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
}
2009-06-30 08:05:37 +00:00
?>