Esempio n. 1
0
        void OnResetPassword(object sender, EventArgs e)
        {
            Debug.Assert(EnablePasswordReset);

            if (RequiresQuestionAndAnswer)
            {
                ResetWithQuestionDialog dialog = new ResetWithQuestionDialog(ServiceAddress, ApplicationName, UserName);
                dialog.ShowDialog();
            }
            else
            {
                using (PasswordManagerProxy passwordManager = new PasswordManagerProxy(ServiceAddress))
                {
                    string newPassword = null;
                    try
                    {
                        newPassword = passwordManager.ResetPassword(ApplicationName, UserName);
                        Clipboard.SetText(newPassword);
                    }
                    catch (SoapException exception)
                    {
                        if (exception.Message.Contains("The user account has been locked out"))
                        {
                            MessageBox.Show("The user account has been locked out", "Credentials Manager", MessageBoxButtons.OK, MessageBoxIcon.Error);
                            return;
                        }
                        throw;
                    }
                    MessageBox.Show("Generated password: "******" " + Environment.NewLine + "The password is avaiable on the clipboard as well.", "Credentials Manager", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }
        }
        void OnResetPassword(object sender,EventArgs e)
        {
            Debug.Assert(EnablePasswordReset);

             if(RequiresQuestionAndAnswer)
             {
            ResetWithQuestionDialog dialog = new ResetWithQuestionDialog(ServiceAddress,ApplicationName,UserName);
            dialog.ShowDialog();
             }
             else
             {
             IPasswordManager passwordManager = UserManagerProviderFactory.CreatePasswordManager(); // new AspNetSqlProviderService(ServiceAddress);
            string newPassword = null;
            try
            {
               newPassword = passwordManager.ResetPassword(ApplicationName,UserName);
               Clipboard.SetText(newPassword);
            }
            catch(SoapException exception)
            {
               if(exception.Message.Contains("The user account has been locked out"))
               {
                  MessageBox.Show("The user account has been locked out","Credentials Manager",MessageBoxButtons.OK,MessageBoxIcon.Error);
                  return;
               }
               throw;
            }
            MessageBox.Show("Generated password: "******" " + Environment.NewLine + "The password is avaiable on the clipboard as well.","Credentials Manager",MessageBoxButtons.OK,MessageBoxIcon.Information);
             }
        }