diff --git a/PROMS/VEPROMS User Interface/frmManageUser.Designer.cs b/PROMS/VEPROMS User Interface/frmManageUser.Designer.cs index 8197fc6d..0a311d94 100644 --- a/PROMS/VEPROMS User Interface/frmManageUser.Designer.cs +++ b/PROMS/VEPROMS User Interface/frmManageUser.Designer.cs @@ -48,7 +48,6 @@ namespace VEPROMS // btnSave // this.btnSave.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); - this.btnSave.DialogResult = System.Windows.Forms.DialogResult.OK; this.btnSave.Location = new System.Drawing.Point(452, 18); this.btnSave.Name = "btnSave"; this.btnSave.Size = new System.Drawing.Size(75, 23); @@ -60,7 +59,6 @@ namespace VEPROMS // btnCancel // this.btnCancel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); - this.btnCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel; this.btnCancel.Location = new System.Drawing.Point(533, 18); this.btnCancel.Name = "btnCancel"; this.btnCancel.Size = new System.Drawing.Size(75, 23); diff --git a/PROMS/VEPROMS User Interface/frmManageUser.cs b/PROMS/VEPROMS User Interface/frmManageUser.cs index e0396a64..b127b668 100644 --- a/PROMS/VEPROMS User Interface/frmManageUser.cs +++ b/PROMS/VEPROMS User Interface/frmManageUser.cs @@ -29,20 +29,25 @@ namespace VEPROMS private void btnSave_Click(object sender, EventArgs e) { - //_MyUser = pgUser.SelectedObject as User; - //if(_MyUser.UserID.StartsWith("[")) - //{ - // MessageBox.Show(string.Format("{0} is an invalid UserID",_MyUser.UserID)); - // return; - //} - //_MyUser.Save(); - //this.DialogResult = DialogResult.OK; + _MyUser = (pgUser.SelectedObject as SimpleUser).MyUser; + if (_MyUser.UserID.StartsWith("[")) + { + MessageBox.Show(string.Format("{0} is an invalid UserID", _MyUser.UserID)); + return; + } + if (_MyUser.UserID == string.Empty) + { + MessageBox.Show("A blank UserID is an invalid UserID"); + return; + } + _MyUser.Save(); + this.DialogResult = DialogResult.OK; } private void btnCancel_Click(object sender, EventArgs e) { - //_MyUser = User.Get(_MyUser.UID); - //this.DialogResult = DialogResult.Cancel; + _MyUser = User.Get(_MyUser.UID); + this.DialogResult = DialogResult.Cancel; } } internal class SimpleUser @@ -90,7 +95,7 @@ namespace VEPROMS public string UserID { get { return _MyUser.UserID; } - set { _MyUser.UserID = value; _MyUser.UsrID = value; } + set { _MyUser.UserID = value.Trim(); _MyUser.UsrID = value.Trim(); } } } } \ No newline at end of file diff --git a/PROMS/VEPROMS User Interface/frmVEPROMS.cs b/PROMS/VEPROMS User Interface/frmVEPROMS.cs index 5aa53c6c..f94768cc 100644 --- a/PROMS/VEPROMS User Interface/frmVEPROMS.cs +++ b/PROMS/VEPROMS User Interface/frmVEPROMS.cs @@ -696,6 +696,7 @@ namespace VEPROMS private SessionInfo MySessionInfo; private System.Threading.Timer MyActivityTimer; private DevComponents.DotNetBar.ButtonItem btnManageSecurity; + private DevComponents.DotNetBar.ButtonItem btnResetSecurity; private TabItemsToClose _MyCloseTabList = new TabItemsToClose(); public TabItemsToClose MyCloseTabList { @@ -719,6 +720,13 @@ namespace VEPROMS btnManageSecurity = new ButtonItem("btnManageSecurity", "Manage Security"); btnAdmin.SubItems.Add(btnManageSecurity); btnManageSecurity.Click += new EventHandler(btnManageSecurity_Click); + //added by jcb + //menu item to reset security + //requires password to implement + btnResetSecurity = new ButtonItem("btnResetSecurity", "Reset Security"); + btnAdmin.SubItems.Add(btnResetSecurity); + btnResetSecurity.Click += new EventHandler(btnResetSecurity_Click); + //end added by jcb UserInfo ui = null; try { @@ -740,6 +748,7 @@ namespace VEPROMS bool isVisible = ui.IsAdministrator(); btnManageSecurity.Visible = isVisible; btnUpdateFormats.Visible = isVisible; + btnResetSecurity.Visible = isVisible; tmrCloseTabItems = new Timer(); tmrCloseTabItems.Interval = 100; tmrCloseTabItems.Tick += new EventHandler(tmrCloseTabItems_Tick); @@ -913,6 +922,69 @@ namespace VEPROMS dlgManageSecurity dlg = new dlgManageSecurity(); dlg.ShowDialog(this); } + void btnResetSecurity_Click(object sender, EventArgs e) + { + string password = string.Empty; + if (ShowInputDialog(ref password) == DialogResult.OK) + { + if(password == "V3Pr0m5") + { + StringBuilder sb = new StringBuilder(); + sb.AppendLine("***** WARNING *****"); + sb.AppendLine(); + sb.AppendLine("This action will delete all Groups, Users and Memberships from the database."); + sb.AppendLine("This action is NOT reversible."); + sb.AppendLine("Following this action the application will terminate."); + sb.AppendLine(); + sb.AppendLine("Are you sure you want to continue?"); + if (MessageBox.Show(sb.ToString(), "Confirm Security Reset", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Stop) == DialogResult.Yes) + { + ResetSecurity.Execute(); + Application.Exit(); + } + } + else + MessageBox.Show("You have entered an incorrect password."); + } + } + private static DialogResult ShowInputDialog(ref string input) + { + System.Drawing.Size size = new System.Drawing.Size(200, 70); + Form inputBox = new Form(); + + inputBox.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog; + inputBox.ClientSize = size; + inputBox.Text = "Enter Password"; + inputBox.StartPosition = FormStartPosition.CenterScreen; + + System.Windows.Forms.TextBox textBox = new TextBox(); + textBox.Size = new System.Drawing.Size(size.Width - 10, 23); + textBox.Location = new System.Drawing.Point(5, 5); + textBox.PasswordChar = '*'; + textBox.Text = input; + inputBox.Controls.Add(textBox); + + Button okButton = new Button(); + okButton.DialogResult = System.Windows.Forms.DialogResult.OK; + okButton.Name = "okButton"; + okButton.Size = new System.Drawing.Size(75, 23); + okButton.Text = "&OK"; + okButton.Location = new System.Drawing.Point(size.Width - 80 - 80, 39); + inputBox.Controls.Add(okButton); + + Button cancelButton = new Button(); + cancelButton.DialogResult = System.Windows.Forms.DialogResult.Cancel; + cancelButton.Name = "cancelButton"; + cancelButton.Size = new System.Drawing.Size(75, 23); + cancelButton.Text = "&Cancel"; + cancelButton.Location = new System.Drawing.Point(size.Width - 80, 39); + inputBox.Controls.Add(cancelButton); + + + DialogResult result = inputBox.ShowDialog(); + input = textBox.Text; + return result; + } void tc_StatusChanged(object sender, DisplayTabControlStatusEventArgs args) { diff --git a/PROMS/VEPROMS.CSLA.Library/Extension/MultiUserExt.cs b/PROMS/VEPROMS.CSLA.Library/Extension/MultiUserExt.cs index 2872bb40..69c5500a 100644 --- a/PROMS/VEPROMS.CSLA.Library/Extension/MultiUserExt.cs +++ b/PROMS/VEPROMS.CSLA.Library/Extension/MultiUserExt.cs @@ -256,6 +256,39 @@ namespace VEPROMS.CSLA.Library // } //} } + public class ResetSecurity : CommandBase + { + private static readonly log4net.ILog _MyLog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); + #region Factory Methods + public static void Execute() + { + ResetSecurity cmd = new ResetSecurity(); + DataPortal.Execute(cmd); + } + #endregion + #region Server-Side code + protected override void DataPortal_Execute() + { + try + { + using (SqlConnection cn = Database.VEPROMS_SqlConnection) + { + using (SqlCommand cmd = new SqlCommand("vesp_ResetSecurity", cn)) + { + cmd.CommandType = CommandType.StoredProcedure; + cmd.CommandTimeout = 0; + cmd.ExecuteNonQuery(); + } + } + } + catch (Exception ex) + { + if (_MyLog.IsErrorEnabled) _MyLog.Error("Reset Security Error", ex); + throw new ApplicationException("Failure on Reset Security", ex); + } + } + #endregion + } public class SessionPing : CommandBase { private static readonly log4net.ILog _MyLog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);