protected void ResetBtn_Click(object sender, EventArgs e) { String response = ""; bool success = true; String passwd = RandomizeCB.Checked ? WebhostMySQLConnection.AccountManagement.AccountManagement.GenerateRandomPassword() : NewPasswordInput.Text; try { PasswordReset.ChangeAllPasswords(EmailSelect.SelectedValue, "", passwd, "dublinschool.org", true); response = String.Format("Password for {0}@dublinschool.org has been set to {1}{2}Please visit https://webhost.dublinschool.org/PasswordInitialization.aspx to set your own password.", EmailSelect.SelectedValue, passwd, Environment.NewLine); } catch (GoogleAPICall.GoogleAPIException ge) { response = ge.Message; Exception inner = ge.InnerException; while (inner != null) { response += Environment.NewLine + inner.Message; inner = inner.InnerException; } success = false; LogError("Failed to reset password:{0}{0}{1}", Environment.NewLine, response); } if (success && !ResetInfoEmail.Text.Equals("")) { MailControler.MailToUser("Password Reset", response, ResetInfoEmail.Text, EmailSelect.SelectedValue); } MailControler.MailToWebmaster("Password Reset Info", response); LogInformation("Password for {0} has been reset by {1}", EmailSelect.SelectedValue, bPage.user.Name); }
protected void ResetBtn_Click(object sender, EventArgs e) { State.log.WriteLine("Attempting to reset password."); LogInformation("Attempting to reset password."); ADSuccessMessage.Text = ""; GoogleSuccessMessage.Text = ""; if (OldPwdInput.Text.Equals("")) { ErrorMessage.Text = "You must type your old password."; LogError("User did not enter their old password."); State.log.WriteLine(ErrorMessage.Text); ErrorPanel.Visible = true; return; } if (!NewPwdInput.Text.Equals(RepeatPwdInput.Text)) { ErrorMessage.Text = "New Password doesn't match Re-entered Password."; LogError("New Password doesn't match."); State.log.WriteLine(ErrorMessage.Text); ErrorPanel.Visible = true; return; } try { State.log.WriteLine("Calling PasswordReset.ChangeAllPasswords"); PasswordReset.ChangeAllPasswords(((BasePage)Page).user.UserName, OldPwdInput.Text, NewPwdInput.Text); } catch (PasswordReset.PasswordException ex) { String Message = ex.Message; Exception inner = ex.InnerException; while (inner != null) { Message += Environment.NewLine + "____________________________________" + Environment.NewLine + inner.Message; inner = inner.InnerException; } ErrorMessage.Text = Message; State.log.WriteLine(ErrorMessage.Text); ErrorPanel.Visible = true; LogError(Message); MailControler.MailToWebmaster("Failed to change user password.", String.Format("{0} failed to change their active directory password: {1}", user.UserName, Message), user); return; } catch (WebhostMySQLConnection.GoogleAPI.GoogleAPICall.GoogleAPIException gae) { String message = gae.Message; Exception inner = gae.InnerException; while (inner != null) { message += Environment.NewLine + "_____________________________________" + Environment.NewLine + inner.Message; inner = inner.InnerException; } MailControler.MailToWebmaster("Google Password Reset Failed...", message, ((BasePage)Page).user); State.log.WriteLine(message); LogError(message); GoogleSuccessMessage.Text = "Failed to Change Google Password."; } ADSuccessMessage.Text = "Successfully Changed Active Directory Password."; State.log.WriteLine("AD Password Changed Successfully."); if (GoogleSuccessMessage.Text.Equals("")) { GoogleSuccessMessage.Text = "Successfully Changed Google Password."; State.log.WriteLine("Google Password Changed Successfully."); } MailControler.MailToWebmaster("Successfully Changed Password", String.Format("for {0}", user.UserName), user); SuccessPanel.Visible = true; }