summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: ae0ee7d)
raw | patch | inline | side by side (parent: ae0ee7d)
author | hickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Thu, 9 Sep 2010 08:31:39 +0000 (08:31 +0000) | ||
committer | hickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Thu, 9 Sep 2010 08:31:39 +0000 (08:31 +0000) |
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@19577 594d385d-05f5-0310-b6e9-bd551577e9d8
index 9315fe63a406642ccd43c9beda4aa38099b8fd24..10ff4be06026e4300636a59b8bb9c306b3552164 100644 (file)
);
msg_dialog::displayChecks($message);
} else {
- if ($method != "") {
- change_password($ui->dn, $_POST['new_password'], 0, $method);
- } else {
- change_password($ui->dn, $_POST['new_password']);
+ if(!change_password($ui->dn, $_POST['new_password'], FALSE, $method,get_post('current_password'),$msg)){
+ msg_dialog::displayChecks(array($msg));
+ }else{
+ gosa_log("User/password has been changed");
+ $smarty->assign("changed", true);
}
- gosa_log("User/password has been changed");
- $smarty->assign("changed", true);
}
}
index 532adb15720add634ae0007878dfe6b4113b0bce..ff1e8b6c520656b6a6bcabe78343de21032d688a 100644 (file)
{
foreach($this->a_handles as $i_id => $o_handle){
if($o_handle->password_change_needed() && isset($o_handle->by_object['user'])){
- new msg_dialog(_("Reset password"),_("The user password has been reset. Please set a new password!"),WARNING_DIALOG);
- change_password ($o_handle->dn, "",0, $o_handle->by_object['user']->pw_storage);
+ if(!change_password ($o_handle->dn, "",FALSE, $o_handle->by_object['user']->pw_storage,'',$message)){
+ msg_dialog::displayChecks(array($message));
+ }else{
+ new msg_dialog(_("Reset password"),_("The user password has been reset. Please set a new password!"),WARNING_DIALOG);
+ }
}
}
return(FALSE);
index b830351f68b18ddb8efa34bbb4c703cacf4ccf19..f423f80d4a84ae6b7bcdf0c7d560f639ff8a21d2 100644 (file)
@@ -3072,11 +3072,11 @@ function change_password ($dn, $password, $mode=FALSE, $hash= "", $old_password
$attrs['userPassword']= $newpass;
// Prepare prevent hook call
- $attrsPre = $attrs;
- $attrsPre['current_password'] = $old_password;
- $attrsPre['new_password'] = $password;
+ $attrsEvent = $attrs;
+ $attrsEvent['current_password'] = escapeshellarg($old_password);
+ $attrsEvent['new_password'] = escapeshellarg($password);
$passwordPlugin = new password($config,$dn);
- plugin::callHook($passwordPlugin, 'PREMODIFY', $attrs, $output,$retCode,$error, $directlyPrintError = FALSE);
+ plugin::callHook($passwordPlugin, 'PREMODIFY', $attrsEvent, $output,$retCode,$error, $directlyPrintError = FALSE);
if($retCode === 0 && count($output)){
$message = sprintf(_("Pre-event hook reported a problem: %s. Password change canceled!"),implode($output));
return(FALSE);
@@ -3091,7 +3091,7 @@ function change_password ($dn, $password, $mode=FALSE, $hash= "", $old_password
$test->lock_account($config,$dn);
}
- // Check if everythin went fine and then call the post event hooks.
+ // Check if everything went fine and then call the post event hooks.
// If an error occures, then try to rollback the complete actions done.
$preRollback = FALSE;
$ldapRollback = FALSE;
@@ -3113,14 +3113,10 @@ function change_password ($dn, $password, $mode=FALSE, $hash= "", $old_password
}else{
// Execute the password hook
- plugin::callHook($passwordPlugin, 'POSTMODIFY', $attrs, $output,$retCode,$error, $directlyPrintError = FALSE);
+ plugin::callHook($passwordPlugin, 'POSTMODIFY', $attrsEvent, $output,$retCode,$error, $directlyPrintError = FALSE);
if($retCode === 0){
if(count($output)){
new log("modify","users/passwordMethod",$dn,array(),"Password change - Post mdoify hook reported! - FAILED!");
- $attrs = array();
- $attrs['userPassword'] = escapeshellarg($password);
- $attrs['current_password'] = escapeshellarg($password);
- $attrs['old_password'] = escapeshellarg($old_password);
$message = sprintf(_("Post-event hook reported a problem: %s. Password change canceled!"),implode($output));
$ldapRollback = TRUE;
$preRollback = TRUE;
@@ -3143,18 +3139,22 @@ function change_password ($dn, $password, $mode=FALSE, $hash= "", $old_password
}
// Setting password in the ldap database or further operation failed, we should now execute
- // the plugins post-event hook, using switched passwords new/old password.
+ // the plugins pre-event hook, using switched passwords new/old password.
// This ensures that passwords which were set outside of GOsa, will be reset to its
// starting value.
- if($preRollback && !empty($old_password)){
- new log("modify","users/passwordMethod",$dn,array(),"Rolling back postmodify hook!");
- $attrs = array();
- $attrs['current_password'] = escapeshellarg($password);
- $attrs['new_password'] = escapeshellarg($old_password);
- plugin::callHook($passwordPlugin, 'POSTMODIFY', $attrs, $output,$retCode,$error, $directlyPrintError = FALSE);
+ if($preRollback){
+ new log("modify","users/passwordMethod",$dn,array(),"Rolling back premodify hook!");
+ $oldpass= $test->generate_hash($old_password);
+ $attrsEvent['current_password'] = escapeshellarg($password);
+ $attrsEvent['new_password'] = escapeshellarg($old_password);
+ foreach(array("userPassword","sambaNTPassword","sambaLMPassword") as $attr){
+ if(isset($initialAttrs[$attr][0])) $attrsEvent[$attr] = $initialAttrs[$attr][0];
+ }
+
+ plugin::callHook($passwordPlugin, 'PREMODIFY', $attrsEvent, $output,$retCode,$error, $directlyPrintError = FALSE);
if($retCode === 0 && count($output)){
- $message = sprintf(_("Post-event hook reported a problem: %s. Password change canceled!"),implode($output));
- new log("modify","users/passwordMethod",$dn,array(),"Rolling back postmodify hook! - FAILED!");
+ $message = sprintf(_("Pre-event hook reported a problem: %s. Password change canceled!"),implode($output));
+ new log("modify","users/passwordMethod",$dn,array(),"Rolling back premodify hook! - FAILED!");
}
}
@@ -3164,7 +3164,7 @@ function change_password ($dn, $password, $mode=FALSE, $hash= "", $old_password
new log("modify","users/passwordMethod",$dn,array(),"Rolling back ldap modifications!");
$attrs = array();
foreach(array("userPassword","sambaNTPassword","sambaLMPassword") as $attr){
- $attrs[$attr] = $initialAttrs[$attr][0];
+ if(isset($initialAttrs[$attr][0])) $attrs[$attr] = $initialAttrs[$attr][0];
}
$ldap->cd($dn);
$ldap->modify($attrs);
diff --git a/gosa-core/plugins/admin/users/class_userManagement.inc b/gosa-core/plugins/admin/users/class_userManagement.inc
index af2658688d078d5034be5cc05213decad355e521..0e97d648a2e46e4c2892aef0437d0a64ff58d0f5 100644 (file)
// Change cassword
if(isset($this->force_hash_type[$this->dn])){
- if(!change_password ($this->dn, $new_password,0,$this->force_hash_type[$this->dn])){
+ if(!change_password ($this->dn, $new_password,0,$this->force_hash_type[$this->dn],'', $message)){
+ msg_dialog::displayChecks(array($message));
return($smarty->fetch(get_template_path('password.tpl', TRUE)));
}
}else{
- if(!change_password ($this->dn, $new_password)){
+ if(!change_password ($this->dn, $new_password,0,'','',$message)){
+ msg_dialog::displayChecks(array($message));
return($smarty->fetch(get_template_path('password.tpl', TRUE)));
}
}