isReadOnly())
pla_error(_('You cannot perform updates while server is in read-only mode'));
$dn = $_POST['dn'];
$old_values = $_POST['old_values'];
$new_values = $_POST['new_values'];
$encoded_dn = rawurlencode($dn);
$rdn = get_rdn($dn);
echo '
';
printf('
%s
',htmlspecialchars($rdn));
printf('
%s: %s %s: %s
',
_('Server'),$ldapserver->name,_('Distinguished Name'),htmlspecialchars($dn));
echo "\n\n";
run_hook('pre_update_array_processing',array('server_id'=>$ldapserver->server_id,
'dn'=>$dn,'old_values'=>$old_values,'new_values'=>$new_values));
$update_array = array();
foreach ($old_values as $attr => $old_val) {
# Did the user delete the field?
if (! isset($new_values[$attr]))
$update_array[$attr] = '';
# Did the user change the field?
elseif ($old_val !== $new_values[$attr]) {
$new_val = $new_values[$attr];
# Special case for userPassword attributes
if (strcasecmp($attr,'userPassword') == 0) {
foreach ($new_val as $key => $userpassword) {
if (trim($userpassword))
$new_val[$key] = password_hash($userpassword,$_POST['enc_type'][$key]);
else
unset($new_val[$key]);
}
$password_already_hashed = true;
# Special case for samba password
} elseif (strcasecmp($attr,'sambaNTPassword') == 0 && trim($new_val[0])) {
$sambapassword = new smbHash;
$new_val[0] = $sambapassword->nthash($new_val[0]);
# Special case for samba password
} elseif (strcasecmp($attr,'sambaLMPassword') == 0 && trim($new_val[0])) {
$sambapassword = new smbHash;
$new_val[0] = $sambapassword->lmhash($new_val[0]);
}
# Retest in case our now encoded password is the same.
if ($new_val === $old_val)
continue;
if ($new_val)
$update_array[$attr] = $new_val;
}
}
# Check user password with new encoding.
if (isset($new_values['userpassword']) && is_array($new_values['userpassword'])) {
foreach ($new_values['userpassword'] as $key => $userpassword) {
if ($userpassword) {
if ($old_values['userpassword'][$key] == $new_values['userpassword'][$key] &&
get_enc_type($old_values['userpassword'][$key]) == $_POST['enc_type'][$key])
continue;
$new_values['userpassword'][$key] = password_hash($userpassword,$_POST['enc_type'][$key]);
}
}
if ($old_values['userpassword'] != $new_values['userpassword'])
$update_array['userpassword'] = $new_values['userpassword'];
}
# strip empty vals from update_array and ensure consecutive indices for each attribute
foreach ($update_array as $attr => $val) {
if (is_array($val)) {
foreach($val as $i => $v)
if (null == $v || 0 == strlen($v))
unset($update_array[$attr][$i]);
$update_array[$attr] = array_values($update_array[$attr]);
}
}
/* At this point, the update_array should look like this (example):
Array(
cn => Array(
[0] => 'Dave',
[1] => 'Bob')
sn => 'Smith',
telephoneNumber => '555-1234')
This array should be ready to be passed to ldap_modify() */
run_hook('post_update_array_processing',array('server_id'=>$ldapserver->server_id,
'dn'=>$dn,'update_array'=>$update_array));
if (count($update_array) > 0) {
echo ' ';
echo '
';
echo _('Do you want to make these changes?');
echo '
';
#
echo "\n\n";
echo '';
echo '
';
} else {
echo '
';
echo _('You made no changes');
printf(' %s.',
$ldapserver->server_id,$encoded_dn,_('Go back'));
echo '