private void BtnOK_Click(Object Sender, EventArgs e) { string MessageTitle = Catalog.GetString("Set Password"); string ErrorMessage = String.Format(Catalog.GetString("There was a problem setting the password for user {0}."), UserName); if (txtOldPassword.Visible && !TRemote.MSysMan.Maintenance.WebConnectors.PasswordAuthentication(UserName, this.txtOldPassword.Text)) { MessageBox.Show(Catalog.GetString("Incorrect password entered."), MessageTitle, MessageBoxButtons.OK, MessageBoxIcon.Error); } if (txtNewPassword.Text != txtNewPassword2.Text) { MessageBox.Show(Catalog.GetString("Passwords do not match! Please try again..."), MessageTitle, MessageBoxButtons.OK, MessageBoxIcon.Error); return; } if (txtNewPassword.Text == this.txtOldPassword.Text && this.PasswordNeedsChanged) { MessageBox.Show(String.Format(Catalog.GetString( "This password is the same as your old password! Please enter a new password."), UserName), MessageTitle, MessageBoxButtons.OK, MessageBoxIcon.Error); return; } TVerificationResultCollection VerificationResultCollection; TVerificationResult VerificationResult; if (!TSharedSysManValidation.CheckPasswordQuality(txtNewPassword.Text, out VerificationResult)) { MessageBox.Show(ErrorMessage + Environment.NewLine + Environment.NewLine + VerificationResult.ResultText, MessageTitle, MessageBoxButtons.OK, MessageBoxIcon.Error); return; } if (!TRemote.MSysMan.Maintenance.WebConnectors.SetUserPassword(UserName, txtNewPassword.Text, txtOldPassword.Text, PasswordNeedsChanged, out VerificationResultCollection)) { MessageBox.Show(ErrorMessage + Environment.NewLine + Environment.NewLine + VerificationResultCollection.BuildVerificationResultString(), MessageTitle, MessageBoxButtons.OK, MessageBoxIcon.Error); return; } MessageBox.Show(String.Format(Catalog.GetString("Password was successfully set for user {0}."), UserName), MessageTitle); this.DialogResult = DialogResult.OK; }
private void BtnOK_Click(Object Sender, EventArgs e) { if (txtNewPassword.Text != txtNewPassword2.Text) { MessageBox.Show(Catalog.GetString("Passwords do not match! Please try again...")); return; } if (txtNewPassword.Text == this.txtOldPassword.Text && this.PasswordNeedsChanged) { MessageBox.Show(String.Format(Catalog.GetString( "Password not changed as the old password was reused. Please use a new password."), Catalog.GetString("Error"))); return; } TVerificationResultCollection VerificationResultCollection; TVerificationResult VerificationResult; if (!TSharedSysManValidation.CheckPasswordQuality(txtNewPassword.Text, out VerificationResult)) { MessageBox.Show(String.Format(Catalog.GetString( "There was a problem setting the password for user {0}."), UserName) + Environment.NewLine + VerificationResult.ResultText); return; } if (!TRemote.MSysMan.Maintenance.WebConnectors.SetUserPassword(UserName, txtNewPassword.Text, txtOldPassword.Text, PasswordNeedsChanged, out VerificationResultCollection)) { MessageBox.Show(String.Format(Catalog.GetString( "There was a problem setting the password for user {0}."), UserName) + Environment.NewLine + VerificationResultCollection.BuildVerificationResultString()); return; } MessageBox.Show(String.Format(Catalog.GetString("Password was successfully set for user {0}"), UserName), Catalog.GetString("Success")); this.DialogResult = DialogResult.OK; }
/// <summary> /// create a new password for the current user /// </summary> public static bool CreateNewPassword(string AUserName, string AOldPassword, bool APasswordNeedsChanged) { // repeat if an invalid password is entered while (true) { PetraInputBox input = new PetraInputBox( Catalog.GetString("Change your password"), Catalog.GetString("Please enter the new password:"******"", true); if (input.ShowDialog() == DialogResult.OK) { string password = input.GetAnswer(); TVerificationResultCollection VerificationResultCollection; TVerificationResult VerificationResult; if (password == AOldPassword) { MessageBox.Show(String.Format(Catalog.GetString( "Password not changed as the old password was entered. Please enter a new password."), AUserName)); } else if (TSharedSysManValidation.CheckPasswordQuality(password, out VerificationResult)) { // if first password is valid then ask user to enter it again input = new PetraInputBox( Catalog.GetString("Change your password"), Catalog.GetString("Please enter the new password once more:"), "", true); if (input.ShowDialog() == DialogResult.OK) { // if both passwords are the same then save if (password == input.GetAnswer()) { if (TRemote.MSysMan.Maintenance.WebConnectors.SetUserPassword(AUserName, password, AOldPassword, APasswordNeedsChanged, out VerificationResultCollection)) { MessageBox.Show(String.Format(Catalog.GetString("Password was successfully set for user {0}"), AUserName)); return(true); } else { MessageBox.Show(String.Format(Catalog.GetString( "There was a problem setting the password for user {0}."), AUserName) + Environment.NewLine + VerificationResultCollection.BuildVerificationResultString()); break; } } else { MessageBox.Show("Passwords do not match! Please try again..."); } } else { break; } } else { MessageBox.Show(String.Format(Catalog.GetString( "There was a problem setting the password for user {0}."), AUserName) + Environment.NewLine + VerificationResult.ResultText); } } else { break; } } return(false); }
private void BtnOK_Click(Object Sender, EventArgs e) { TVerificationResultCollection VerificationResultCollection; // Client-side checks if (txtOldPassword.Text.Length == 0) { MessageBox.Show(Catalog.GetString("You must enter the current password."), CommonDialogsResourcestrings.StrChangePasswordTitle, MessageBoxButtons.OK, MessageBoxIcon.Error); txtOldPassword.Focus(); return; } if (txtNewPassword.Text.Length == 0) { MessageBox.Show(Catalog.GetString("You must enter a new password."), CommonDialogsResourcestrings.StrChangePasswordTitle, MessageBoxButtons.OK, MessageBoxIcon.Error); txtNewPassword.Focus(); return; } if (txtNewPassword2.Text.Length == 0) { MessageBox.Show(Catalog.GetString("You must repeat the new password."), CommonDialogsResourcestrings.StrChangePasswordTitle, MessageBoxButtons.OK, MessageBoxIcon.Error); txtNewPassword2.Focus(); return; } if (txtNewPassword.Text != txtNewPassword2.Text) { MessageBox.Show(Catalog.GetString("The new password and the repeated new password are not identical! Please enter them again."), CommonDialogsResourcestrings.StrChangePasswordTitle, MessageBoxButtons.OK, MessageBoxIcon.Error); txtNewPassword.Focus(); txtNewPassword.SelectAll(); return; } try { this.Cursor = Cursors.WaitCursor; Application.DoEvents(); // give Windows a chance to update the Cursor // Request the setting of the new password (incl. server-side checks) if (!TRemote.MSysMan.Maintenance.WebConnectors.SetUserPassword(UserName, txtNewPassword.Text, txtOldPassword.Text, PasswordNeedsChanged, TClientInfo.ClientComputerName, TClientInfo.ClientIPAddress, out VerificationResultCollection)) { MessageBox.Show(String.Format(CommonDialogsResourcestrings.StrChangePasswordError, UserName) + Environment.NewLine + Environment.NewLine + VerificationResultCollection.BuildVerificationResultString(), CommonDialogsResourcestrings.StrChangePasswordTitle, MessageBoxButtons.OK, MessageBoxIcon.Error); txtNewPassword.Focus(); txtNewPassword.SelectAll(); return; } MessageBox.Show(String.Format(Catalog.GetString(CommonDialogsResourcestrings.StrChangePasswordSuccess), UserName), CommonDialogsResourcestrings.StrChangePasswordTitle, MessageBoxButtons.OK, MessageBoxIcon.Information); } finally { this.Cursor = Cursors.Default; } this.DialogResult = DialogResult.OK; }