/// <summary> /// BTNSendByMail_Click event /// </summary> private void BTNSendByMail_Click(object sender, EventArgs e) { Cursor crs = this.Cursor; int cnt = 0; try { this.Cursor = Cursors.WaitCursor; RegistrationList lst = userPropertyPage.GetSharedUserData(); foreach (Registration reg in lst) { string secret = MMCService.GetEncodedUserKey(reg.UPN); MMCService.SendKeyByEmail(reg.MailAddress, reg.UPN, secret); cnt++; } } catch (Exception ex) { this.Cursor = crs; MessageBoxParameters messageBoxParameters = new MessageBoxParameters(); messageBoxParameters.Text = ex.Message; messageBoxParameters.Buttons = MessageBoxButtons.OK; messageBoxParameters.Icon = MessageBoxIcon.Error; userPropertyPage.ParentSheet.ShowDialog(messageBoxParameters); } finally { this.Cursor = crs; MessageBoxParameters messageBoxParameters = new MessageBoxParameters(); messageBoxParameters.Text = string.Format(errors_strings.InfosSendingMails, cnt); messageBoxParameters.Buttons = MessageBoxButtons.OK; messageBoxParameters.Icon = MessageBoxIcon.Information; userPropertyPage.ParentSheet.ShowDialog(messageBoxParameters); } }
/// <summary> /// clearkeyBtn_Click event /// </summary> private void clearkeyBtn_Click(object sender, EventArgs e) { Cursor crs = this.Cursor; try { _secretkey = string.Empty; this.DisplayKey.Text = string.Empty; this.qrCodeGraphic.Text = string.Empty; MMCService.RemoveUserKey(_upn); if (!SyncDisabled) { userPropertyPage.SyncSharedUserData(this, true); } } catch (Exception ex) { this.Cursor = crs; MessageBoxParameters messageBoxParameters = new MessageBoxParameters { Text = ex.Message, Buttons = MessageBoxButtons.OK, Icon = MessageBoxIcon.Error }; userPropertyPage.ParentSheet.ShowDialog(messageBoxParameters); } finally { this.Cursor = crs; } }
/// <summary> /// BTNSendByMail_Click event /// </summary> private void BTNSendByMail_Click(object sender, EventArgs e) { Cursor crs = this.Cursor; try { this.Cursor = Cursors.WaitCursor; MMCService.SendKeyByEmail(_email, _upn, this.DisplayKey.Text); } catch (Exception ex) { this.Cursor = crs; MessageBoxParameters messageBoxParameters = new MessageBoxParameters(); messageBoxParameters.Text = ex.Message; messageBoxParameters.Buttons = MessageBoxButtons.OK; messageBoxParameters.Icon = MessageBoxIcon.Error; userPropertyPage.ParentSheet.ShowDialog(messageBoxParameters); } finally { this.Cursor = crs; MessageBoxParameters messageBoxParameters = new MessageBoxParameters(); messageBoxParameters.Text = string.Format(errors_strings.InfoSendingMailToUser, _email); messageBoxParameters.Buttons = MessageBoxButtons.OK; messageBoxParameters.Icon = MessageBoxIcon.Information; userPropertyPage.ParentSheet.ShowDialog(messageBoxParameters); } }
/// <summary> /// DeleteUserData method implementation /// </summary> internal bool DeleteUserData(MFAUserList registrations) { bool ret = MMCService.DeleteUser(registrations); DeleteRows(registrations); return(ret); }
/// <summary> /// EnsurePageForRowIndex method implmentation /// </summary> private int EnsurePageForRowIndex(int rowindex) { int idx = rowindex % MMCService.Paging.PageSize; int page = (rowindex / MMCService.Paging.PageSize) + 1; if (page != MMCService.Paging.CurrentPage) { UseWaitCursor = true; Cursor = Cursors.WaitCursor; try { MMCService.Paging.CurrentPage = page; _lst = MMCService.GetUsers(); } catch (Exception ex) { MessageBoxParameters messageBoxParameters = new MessageBoxParameters { Text = ex.Message, Buttons = MessageBoxButtons.OK, Icon = MessageBoxIcon.Error }; SnapIn.Console.ShowDialog(messageBoxParameters); } finally { UseWaitCursor = false; Cursor = Cursors.Default; } } return(idx); }
/// <summary> /// RefreshData method implmentation /// </summary> public void RefreshData(bool refreshgrid = false, bool clearselection = false) { this.UseWaitCursor = true; this.Cursor = Cursors.WaitCursor; ComponentResourceManager resources = new ComponentResourceManager(typeof(UsersListView)); this.uPNDataGridViewTextBoxColumn.HeaderText = resources.GetString("uPNDataGridViewTextBoxColumn.HeaderText"); this.mailAddressDataGridViewTextBoxColumn.HeaderText = resources.GetString("mailAddressDataGridViewTextBoxColumn.HeaderText"); this.phoneNumberDataGridViewTextBoxColumn.HeaderText = resources.GetString("phoneNumberDataGridViewTextBoxColumn.HeaderText"); this.preferredMethodDataGridViewTextBoxColumn.HeaderText = resources.GetString("preferredMethodDataGridViewTextBoxColumn.HeaderText"); this.enabledDataGridViewCheckBoxColumn.HeaderText = resources.GetString("enabledDataGridViewCheckBoxColumn.HeaderText"); try { _lst = MMCService.GetUsers(); if (clearselection) { this.GridView.RowCount = 0; } this.GridView.RowCount = _lst.Count; // MMCService.GetUsersCount(); ICI if (refreshgrid) { this.GridView.Refresh(); } if (clearselection) { // this.GridView.ClearSelection(); } } finally { this.UseWaitCursor = false; this.Cursor = Cursors.Default; } }
/// <summary> /// BuildKeysControl method implementation /// </summary> private void BuildKeysControl() { try { List <WebAuthNCredentialInformation> credlist = MMCService.GetUserStoredCredentials(_upn); this.WebAuthN.Controls.Clear(); int i = 1; foreach (WebAuthNCredentialInformation cred in credlist) { CheckBox rdio = new CheckBox { Tag = cred.CredentialID, Top = (i * 25), Left = 25, Width = 125 }; Font fnt = rdio.Font; rdio.Font = new Font(fnt.FontFamily, fnt.Size, FontStyle.Bold, fnt.Unit, fnt.GdiCharSet); rdio.Text = cred.CredType; this.WebAuthN.Controls.Add(rdio); rdio.CheckedChanged += Rdio_CheckedChanged; Label lblName = new Label { Top = (i * 25) + 6, Left = 160, Width = 150, Text = cred.NickName, }; Font xfnt = lblName.Font; lblName.Font = new Font(fnt.FontFamily, fnt.Size, FontStyle.Bold, fnt.Unit, fnt.GdiCharSet); this.WebAuthN.Controls.Add(lblName); Label lbl = new Label { Top = (i * 25) + 6, Left = 315, Width = 65, Text = cred.RegDate.ToShortDateString() }; this.WebAuthN.Controls.Add(lbl); Label cnt = new Label(); Font fntcnt = cnt.Font; cnt.Font = new Font(fntcnt.FontFamily, fntcnt.Size, FontStyle.Bold, fntcnt.Unit, fntcnt.GdiCharSet); cnt.Top = (i * 25) + 6; cnt.Left = 385; cnt.Width = 45; cnt.Text = "(" + cred.SignatureCounter.ToString() + ")"; this.WebAuthN.Controls.Add(cnt); i++; } } catch (Exception) { this.WebAuthN.Controls.Clear(); } }
/// <summary> /// newkeyBtn_Click event /// </summary> private void newkeyBtn_Click(object sender, EventArgs e) { MMCService.NewUserKey(_upn); _secretkey = MMCService.GetEncodedUserKey(_upn); this.DisplayKey.Text = _secretkey; this.qrCodeGraphic.Text = MMCService.GetQRCodeValue(_upn, this.DisplayKey.Text); if (!SyncDisabled) { userPropertyPage.SyncSharedUserData(this, true); } }
/// <summary> /// BTNReinit_Click event /// </summary> private void BTNReinit_Click(object sender, EventArgs e) { MFAUserList lst = userPropertyPage.GetSharedUserData(); foreach (MFAUser reg in lst) { MMCService.NewUserKey(reg.UPN); } if (!SyncDisabled) { userPropertyPage.SyncSharedUserData(this, true); } }
/// <summary> /// DeleteKeys method implementation /// </summary> private void DeleteKeys() { foreach (Control ctrl in this.WebAuthN.Controls) { if (ctrl is CheckBox) { CheckBox box = ctrl as CheckBox; if (box.Checked) { MMCService.RemoveUserStoredCredentials(_upn, box.Tag.ToString()); } } } }
/// <summary> /// SetUserControlData method implmentation /// </summary> public void SetUserControlData(MFAUserList lst, bool disablesync) { SyncDisabled = disablesync; try { MFAUser obj = lst[0]; _upn = obj.UPN; _email = obj.MailAddress; _secretkey = MMCService.GetEncodedUserKey(obj.UPN); if (string.IsNullOrEmpty(_email)) { this.EmailPrompt.Text = "Email : "; _emailnotset = true; } else { this.EmailPrompt.Text = string.Format("Email : {0}", _email); _emailnotset = false; } if (!string.IsNullOrEmpty(_secretkey)) { this.DisplayKey.Text = _secretkey; if (!string.IsNullOrEmpty(_upn)) { this.qrCodeGraphic.Text = MMCService.GetQRCodeValue(_upn, this.DisplayKey.Text); } else { this.qrCodeGraphic.Text = string.Empty; } } else { userPropertyPage.Dirty = true; } UpdateControlsEnabled(); } catch (Exception) { this.DisplayKey.Text = string.Empty; this.qrCodeGraphic.Text = string.Empty; } finally { SyncDisabled = false; } }
/// <summary> /// RefreshData method implmentation /// </summary> public void RefreshData(bool refreshgrid = false, bool clearselection = false) { this.UseWaitCursor = true; this.Cursor = Cursors.WaitCursor; ComponentResourceManager resources = new ComponentResourceManager(typeof(UsersListView)); this.uPNDataGridViewTextBoxColumn.HeaderText = resources.GetString("uPNDataGridViewTextBoxColumn.HeaderText"); this.mailAddressDataGridViewTextBoxColumn.HeaderText = resources.GetString("mailAddressDataGridViewTextBoxColumn.HeaderText"); this.phoneNumberDataGridViewTextBoxColumn.HeaderText = resources.GetString("phoneNumberDataGridViewTextBoxColumn.HeaderText"); this.preferredMethodDataGridViewTextBoxColumn.HeaderText = resources.GetString("preferredMethodDataGridViewTextBoxColumn.HeaderText"); this.enabledDataGridViewCheckBoxColumn.HeaderText = resources.GetString("enabledDataGridViewCheckBoxColumn.HeaderText"); try { _lst = MMCService.GetUsers(); if (clearselection) { GridView.RowCount = 0; } // GridView.RowCount = _lst.Count; GridView.RowCount = MMCService.GetUsersCount(); if (refreshgrid) { GridView.Refresh(); } if (clearselection) { GridView.ClearSelection(); } } catch (Exception ex) { MessageBoxParameters messageBoxParameters = new MessageBoxParameters { Text = ex.Message, Buttons = MessageBoxButtons.OK, Icon = MessageBoxIcon.Error }; SnapIn.Console.ShowDialog(messageBoxParameters); } finally { UseWaitCursor = false; Cursor = Cursors.Default; } }
/// <summary> /// DisableUserData method implementation /// </summary> internal void DisableUserData(MFAUserList registrations) { try { MFAUserList results = MMCService.DisableUser(registrations); EnableDisableRows(results); } catch (Exception ex) { MessageBoxParameters messageBoxParameters = new MessageBoxParameters { Text = ex.Message, Buttons = MessageBoxButtons.OK, Icon = MessageBoxIcon.Error }; SnapIn.Console.ShowDialog(messageBoxParameters); } }
/// <summary> /// SetUserControlData method implmentation /// </summary> public void SetUserControlData(RegistrationList lst, bool disablesync) { SyncDisabled = disablesync; try { Registration obj = ((RegistrationList)lst)[0]; _secretkey = MMCService.GetEncodedUserKey(((Registration)obj).UPN); // _secretkey = KeysManager.EncodedKey(((Registration)obj).UPN); _upn = ((Registration)obj).UPN; _email = ((Registration)obj).MailAddress; if (string.IsNullOrEmpty(_email)) { this.EmailPrompt.Text = "Adresse email : "; _emailnotset = true; } else { this.EmailPrompt.Text = string.Format("Adresse email : {0}", _email); _emailnotset = false; } if (!string.IsNullOrEmpty(_secretkey)) { this.DisplayKey.Text = _secretkey; if (!string.IsNullOrEmpty(_upn)) { this.qrCodeGraphic.Text = MMCService.GetQRCodeValue(_upn, this.DisplayKey.Text); } else { this.qrCodeGraphic.Text = string.Empty; } } else { userPropertyPage.Dirty = true; } UpdateControlsEnabled(); } finally { SyncDisabled = false; } }
/// <summary> /// BTNSendByMail_Click event /// </summary> private void BTNSendByMail_Click(object sender, EventArgs e) { Cursor crs = this.Cursor; try { this.Cursor = Cursors.WaitCursor; RegistrationList lst = userPropertyPage.GetSharedUserData(); foreach (Registration reg in lst) { string secret = MMCService.GetEncodedUserKey(reg.UPN); MMCService.SendKeyByEmail(reg.MailAddress, reg.UPN, secret); } } finally { this.Cursor = crs; } }
/// <summary> /// DeleteUserData method implementation /// </summary> internal bool DeleteUserData(MFAUserList registrations) { try { bool ret = MMCService.DeleteUser(registrations); DeleteRows(registrations); return(ret); } catch (Exception ex) { MessageBoxParameters messageBoxParameters = new MessageBoxParameters { Text = ex.Message, Buttons = MessageBoxButtons.OK, Icon = MessageBoxIcon.Error }; SnapIn.Console.ShowDialog(messageBoxParameters); return(false); } }
/// <summary> /// EnsurePageForRowIndex method implmentation /// </summary> private int EnsurePageForRowIndex(int rowindex) { int idx = rowindex % MMCService.Paging.PageSize; int page = (rowindex / MMCService.Paging.PageSize) + 1; if (page != MMCService.Paging.CurrentPage) { this.UseWaitCursor = true; this.Cursor = Cursors.WaitCursor; try { MMCService.Paging.CurrentPage = page; _lst = MMCService.GetUsers(); } finally { this.UseWaitCursor = false; this.Cursor = Cursors.Default; } } return(idx); }
/// <summary> /// EnableUserData method implementation /// </summary> internal void EnableUserData(RegistrationList registrations) { RegistrationList results = MMCService.EnableUser(registrations); EnableDisableRows(results); }
/// <summary> /// BTNSendByMail_Click event /// </summary> private void BTNSendByMail_Click(object sender, EventArgs e) { MMCService.SendKeyByEmail(_email, _upn, this.DisplayKey.Text); }
/// <summary> /// SetUserData method implementation /// </summary> internal void SetUserData(MFAUserList registrations) { MMCService.SetUser(registrations); UpdateRows(registrations); }
/// <summary> /// CanApplyDataChanges method implementation /// </summary> private bool CanApplyDataChanges(Registration registration) { bool result = false; if (registration.IsApplied) { return(true); } if (string.IsNullOrEmpty(registration.UPN)) { MessageBoxParameters messageBoxParameters = new MessageBoxParameters(); messageBoxParameters.Text = res.PPAGEVALIDUSER; messageBoxParameters.Buttons = MessageBoxButtons.OK; messageBoxParameters.Icon = MessageBoxIcon.Error; ParentSheet.ShowDialog(messageBoxParameters); ParentSheet.SetActivePage(0); } else if (string.IsNullOrEmpty(MMCService.GetEncodedUserKey(registration.UPN))) { MessageBoxParameters messageBoxParameters = new MessageBoxParameters(); messageBoxParameters.Text = res.PPAGEVALIDKEY; messageBoxParameters.Buttons = MessageBoxButtons.OK; messageBoxParameters.Icon = MessageBoxIcon.Error; ParentSheet.ShowDialog(messageBoxParameters); ParentSheet.SetActivePage(1); } else if (string.IsNullOrEmpty(registration.MailAddress)) { MessageBoxParameters messageBoxParameters = new MessageBoxParameters(); messageBoxParameters.Text = res.PPAGEVALIDMAIL; messageBoxParameters.Buttons = MessageBoxButtons.YesNo; messageBoxParameters.Icon = MessageBoxIcon.Warning; if (ParentSheet.ShowDialog(messageBoxParameters) == DialogResult.Yes) { result = true; } else { ParentSheet.SetActivePage(0); } } else if (!MMCService.IsValidEmail(registration.MailAddress)) { MessageBoxParameters messageBoxParameters = new MessageBoxParameters(); messageBoxParameters.Text = res.PPAGEINVALIDMAIL; messageBoxParameters.Buttons = MessageBoxButtons.OK; messageBoxParameters.Icon = MessageBoxIcon.Error; ParentSheet.ShowDialog(messageBoxParameters); ParentSheet.SetActivePage(0); } else if (string.IsNullOrEmpty(registration.PhoneNumber)) { MessageBoxParameters messageBoxParameters = new MessageBoxParameters(); messageBoxParameters.Text = res.PPAGEVALIDPHONE; messageBoxParameters.Buttons = MessageBoxButtons.YesNo; messageBoxParameters.Icon = MessageBoxIcon.Warning; if (ParentSheet.ShowDialog(messageBoxParameters) == DialogResult.Yes) { result = true; } else { ParentSheet.SetActivePage(0); } } else if (!MMCService.IsValidPhone(registration.PhoneNumber)) { MessageBoxParameters messageBoxParameters = new MessageBoxParameters(); messageBoxParameters.Text = res.PPAGEINVALIDPHONE; messageBoxParameters.Buttons = MessageBoxButtons.OK; messageBoxParameters.Icon = MessageBoxIcon.Error; ParentSheet.ShowDialog(messageBoxParameters); ParentSheet.SetActivePage(0); } else { result = true; } return(result); }
/// <summary> /// CanApplyDataChanges method implementation /// </summary> private bool CanApplyDataChanges(MFAUser registration) { bool result = true; if (registration.IsApplied) { return(result); } IExternalProvider prov1 = RuntimeAuthProvider.GetProviderInstance(PreferredMethod.Code); if (prov1 != null) { if ((prov1.Enabled) && (prov1.IsRequired)) { if (string.IsNullOrEmpty(registration.UPN)) { MessageBoxParameters messageBoxParameters = new MessageBoxParameters { Text = res.PPAGEVALIDUSER, Buttons = MessageBoxButtons.OK, Icon = MessageBoxIcon.Error }; ParentSheet.ShowDialog(messageBoxParameters); ParentSheet.SetActivePage(0); result = false; } else if (string.IsNullOrEmpty(MMCService.GetEncodedUserKey(registration.UPN))) { MessageBoxParameters messageBoxParameters = new MessageBoxParameters { Text = res.PPAGEVALIDKEY, Buttons = MessageBoxButtons.OK, Icon = MessageBoxIcon.Error }; ParentSheet.ShowDialog(messageBoxParameters); ParentSheet.SetActivePage(1); result = false; } } } IExternalProvider prov2 = RuntimeAuthProvider.GetProviderInstance(PreferredMethod.Email); if (prov2 != null) { if ((prov2.Enabled) && (prov2.IsRequired)) { if (string.IsNullOrEmpty(registration.MailAddress)) { MessageBoxParameters messageBoxParameters = new MessageBoxParameters { Text = res.PPAGEVALIDMAIL, Buttons = MessageBoxButtons.YesNo, Icon = MessageBoxIcon.Warning }; if (ParentSheet.ShowDialog(messageBoxParameters) == DialogResult.Yes) { result = true; } else { result = false; ParentSheet.SetActivePage(0); } } else if (!MMCService.IsValidEmail(registration.MailAddress)) { MessageBoxParameters messageBoxParameters = new MessageBoxParameters { Text = res.PPAGEINVALIDMAIL, Buttons = MessageBoxButtons.OK, Icon = MessageBoxIcon.Error }; ParentSheet.ShowDialog(messageBoxParameters); ParentSheet.SetActivePage(0); result = false; } } } IExternalProvider prov3 = RuntimeAuthProvider.GetProviderInstance(PreferredMethod.External); if (prov3 != null) { if ((prov3.Enabled) && (prov3.IsRequired)) { if (string.IsNullOrEmpty(registration.PhoneNumber)) { MessageBoxParameters messageBoxParameters = new MessageBoxParameters { Text = res.PPAGEVALIDPHONE, Buttons = MessageBoxButtons.YesNo, Icon = MessageBoxIcon.Warning }; if (ParentSheet.ShowDialog(messageBoxParameters) == DialogResult.Yes) { result = true; } else { result = false; ParentSheet.SetActivePage(0); } } else if (!MMCService.IsValidPhone(registration.PhoneNumber)) { MessageBoxParameters messageBoxParameters = new MessageBoxParameters { Text = res.PPAGEINVALIDPHONE, Buttons = MessageBoxButtons.OK, Icon = MessageBoxIcon.Error }; ParentSheet.ShowDialog(messageBoxParameters); ParentSheet.SetActivePage(0); result = false; } } } return(result); }
/// <summary> /// DisableUserData method implementation /// </summary> internal void DisableUserData(MFAUserList registrations) { MFAUserList results = MMCService.DisableUser(registrations); EnableDisableRows(results); }
/// <summary> /// AddUserData method implmentation /// </summary> internal void AddUserData(MFAUserList registrations) { MFAUserList results = MMCService.AddUser(registrations); AddRows(results); }