private void SetPassword(Object Sender, EventArgs e)
        {
            if (FPreviouslySelectedDetailRow == null)
            {
                return;
            }

            if (FPetraUtilsObject.HasChanges)
            {
                MessageBox.Show(
                    Catalog.GetString("Please save changes before changing password."),
                    Catalog.GetString("Change password."),
                    MessageBoxButtons.OK,
                    MessageBoxIcon.Stop);
                return;
            }

            string username = GetSelectedDetailRow().UserId;

            string MessageTitle = Catalog.GetString("Set Password");
            string ErrorMessage = String.Format(Catalog.GetString("There was a problem setting the password for user {0}."), username);

            // only request the password once, since this is the sysadmin changing it.
            // see http://bazaar.launchpad.net/~openpetracore/openpetraorg/trunkhosted/view/head:/csharp/ICT/Petra/Client/MSysMan/Gui/SysManMain.cs
            // for the change password dialog for the normal user
            PetraInputBox input = new PetraInputBox(
                Catalog.GetString("Change the password"),
                String.Format(Catalog.GetString("Please enter the new password for user {0}:"), username),
                "", true);

            if (input.ShowDialog() == DialogResult.OK)
            {
                string password = input.GetAnswer();
                TVerificationResult VerificationResult;

                if (TSharedSysManValidation.CheckPasswordQuality(password, out VerificationResult))
                {
                    if (TRemote.MSysMan.Maintenance.WebConnectors.SetUserPassword(username, password, true, true))
                    {
                        MessageBox.Show(String.Format(Catalog.GetString("Password was successfully set for user {0}."), username),
                                        MessageTitle, MessageBoxButtons.OK, MessageBoxIcon.Information);

                        // This has been saved on the server so my data is dirty - I need to re-load:
                        FPreviouslySelectedDetailRow = null;
                        Int32 rowIdx = GetSelectedRowIndex();
                        LoadUsers();
                        grdDetails.SelectRowInGrid(rowIdx);
                    }
                    else
                    {
                        MessageBox.Show(ErrorMessage, MessageTitle, MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                }
                else
                {
                    MessageBox.Show(ErrorMessage + Environment.NewLine + Environment.NewLine + VerificationResult.ResultText,
                                    MessageTitle, MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }
예제 #2
0
        /// <summary>
        /// change the password of the current user
        /// </summary>
        public static void SetUserPassword(Form AParentForm)
        {
            string username = Ict.Petra.Shared.UserInfo.GUserInfo.UserID;

            // TODO: use old password as well, to make sure the password is changed by its owner
            PetraInputBox input = new PetraInputBox(
                Catalog.GetString("Change your password"),
                Catalog.GetString("Please enter the old password:"******"", true);

            if (input.ShowDialog() == DialogResult.OK)
            {
                TLoginForm.CreateNewPassword(username, input.GetAnswer(), false);
            }
        }
        private void OnBtnRcptNumber(Object sender, EventArgs e)
        {
            Boolean IntFormatIsOk = false;
            Int32   ReceiptNum;
            Int32   NewReceiptNum = 0;

            do
            {
                ReceiptNum = TRemote.MFinance.Gift.WebConnectors.GetLastReceiptNumber(FLedgerNumber);
                String        ReceiptNumString = (ReceiptNum + 1).ToString();
                PetraInputBox input            = new PetraInputBox(
                    Catalog.GetString("Receipt Numbers"),
                    Catalog.GetString("The next Gift Receipt will have this number:"),
                    ReceiptNumString, false);
                input.ShowDialog();

                if (input.DialogResult == System.Windows.Forms.DialogResult.Cancel)
                {
                    return;
                }

                ReceiptNumString = input.GetAnswer();
                try
                {
                    NewReceiptNum = Convert.ToInt32(ReceiptNumString) - 1;
                    IntFormatIsOk = true;
                }
                catch (FormatException)
                {
                    MessageBox.Show(
                        Catalog.GetString("Please enter an integer."),
                        Catalog.GetString("Format Problem")
                        );
                }
            } while (!IntFormatIsOk);

            if (NewReceiptNum < ReceiptNum)
            {
                MessageBox.Show(
                    Catalog.GetString("WARNING - new Receipt Number is less than previous number.\r\nDuplicate Receipt Numbers might be printed."),
                    Catalog.GetString("Receipt Numbers"),
                    MessageBoxButtons.OK,
                    MessageBoxIcon.Warning
                    );
            }

            TRemote.MFinance.Gift.WebConnectors.SetLastReceiptNumber(FLedgerNumber, NewReceiptNum);
        }
예제 #4
0
        private void SetPassword(Object Sender, EventArgs e)
        {
            string username = GetSelectedDetailRow().UserId;

            // only request the password once, since this is the sysadmin changing it.
            // see http://bazaar.launchpad.net/~openpetracore/openpetraorg/trunkhosted/view/head:/csharp/ICT/Petra/Client/MSysMan/Gui/SysManMain.cs
            // for the change password dialog for the normal user
            PetraInputBox input = new PetraInputBox(
                Catalog.GetString("Change the password"),
                String.Format(Catalog.GetString("Please enter the new password for user {0}:"), username),
                "", true);

            if (input.ShowDialog() == DialogResult.OK)
            {
                string password = input.GetAnswer();
                TVerificationResult VerificationResult;

                if (TSharedSysManValidation.CheckPasswordQuality(password, out VerificationResult))
                {
                    if (TRemote.MSysMan.Maintenance.WebConnectors.SetUserPassword(username, password, true, true))
                    {
                        MessageBox.Show(String.Format(Catalog.GetString("Password was successfully set for user {0}"), username));

                        // this has already been saved on during the server call to change the password
                        GetSelectedDetailRow().Retired = false;
                    }
                    else
                    {
                        MessageBox.Show(String.Format(Catalog.GetString("There was a problem setting the password for user {0}"), username));
                    }
                }
                else
                {
                    MessageBox.Show(String.Format(Catalog.GetString(
                                                      "There was a problem setting the password for user {0}."), username) +
                                    Environment.NewLine + VerificationResult.ResultText);
                }
            }
        }
예제 #5
0
        private void ResetPassword(Object Sender, EventArgs e)
        {
            TVerificationResultCollection VerificationResultCollection = null;
            string OneTimePassword = String.Empty;
            bool   RandomSecurePasswordUtilised = false;

            if (FPreviouslySelectedDetailRow == null)
            {
                return;
            }

            if (FPetraUtilsObject.HasChanges)
            {
                MessageBox.Show(
                    Catalog.GetString("It is necessary to save any changes before a user's password can be changed." +
                                      Environment.NewLine + "Please save changes now and then repeat the operation."),
                    CommonDialogsResourcestrings.StrResetUserPasswordTitle,
                    MessageBoxButtons.OK,
                    MessageBoxIcon.Stop);
                return;
            }

            string username = GetSelectedDetailRow().UserId;

            var UserChoice = MessageBox.Show(Catalog.GetString(
                                                 "The resetting of a User Password requires the creation of a one-time password that the user will need to enter.\r\n" +
                                                 "OpenPetra can generate a 'random secure' password for this purpose (recommended!). Alternatively, you can come up with such a password manually.\r\n\r\nCreate 'random secure' User Password?"),
                                             Catalog.GetString("User Password Reset"), MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question,
                                             MessageBoxDefaultButton.Button1);

            switch (UserChoice)
            {
            case DialogResult.Yes:
                OneTimePassword = TPasswordHelper.GetRandomSecurePassword();
                RandomSecurePasswordUtilised = true;

                break;

            case DialogResult.No:
                // only request the password once, since this is the sysadmin changing it.
                // see http://bazaar.launchpad.net/~openpetracore/openpetraorg/trunkhosted/view/head:/csharp/ICT/Petra/Client/MSysMan/Gui/SysManMain.cs
                // for the change password dialog for the normal user
                PetraInputBox input = new PetraInputBox(
                    CommonDialogsResourcestrings.StrResetUserPasswordTitle,
                    String.Format(Catalog.GetString("Please enter a one-time password for user {0}:"), username),
                    "", true);

                if (input.ShowDialog() == DialogResult.OK)
                {
                    OneTimePassword = input.GetAnswer();

                    break;
                }
                else
                {
                    ShowResettingOfUserPwdCancelledMessage();

                    return;
                }

            case DialogResult.Cancel:
                ShowResettingOfUserPwdCancelledMessage();

                return;
            }

            try
            {
                this.Cursor = Cursors.WaitCursor;
                Application.DoEvents();  // give Windows a chance to update the Cursor

                // Save the new password (server-side checks get performed)
                if (TRemote.MSysMan.Maintenance.WebConnectors.SetUserPassword(username, OneTimePassword, true, true,
                                                                              TClientInfo.ClientComputerName, TClientInfo.ClientIPAddress,
                                                                              out VerificationResultCollection))
                {
                    MessageBox.Show(String.Format(Catalog.GetString(CommonDialogsResourcestrings.StrChangePasswordSuccess +
                                                                    Environment.NewLine +
                                                                    (RandomSecurePasswordUtilised ? Catalog.GetString(
                                                                         "The 'random secure' password will get copied to the clipboard after you have closed this message. Follow the steps lined out in the next message!")
                                                                     +
                                                                     Environment.NewLine : String.Empty) +
                                                                    Environment.NewLine +
                                                                    "(The user must change the new password for a password of his/her choice the next time (s)he logs on.)"),
                                                  username), CommonDialogsResourcestrings.StrResetUserPasswordTitle,
                                    MessageBoxButtons.OK, MessageBoxIcon.Information);

                    if (RandomSecurePasswordUtilised)
                    {
                        CopyPasswordIntoClipboard(OneTimePassword);
                    }

                    // This has been saved on the server so my data is out-of-date - re-loading needed to get new
                    // ModificationId etc:
                    FPreviouslySelectedDetailRow = null;
                    Int32 rowIdx = GetSelectedRowIndex();

                    LoadUsers();

                    grdDetails.SelectRowInGrid(rowIdx);
                }
                else
                {
                    MessageBox.Show(String.Format(CommonDialogsResourcestrings.StrChangePasswordError, username) +
                                    Environment.NewLine + Environment.NewLine +
                                    VerificationResultCollection.BuildVerificationResultString(),
                                    CommonDialogsResourcestrings.StrResetUserPasswordTitle,
                                    MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
            }
            finally
            {
                this.Cursor = Cursors.Default;
            }
        }