private void BeginResolve() { if (textBoxUserNames.Text.Trim().Length == 0) { return; } entryListView.Visible = true; progressBar1.Visible = true; textBoxUserNames.Enabled = false; buttonGrantAccess.Enabled = false; LabelStatus.Visible = true; textBoxUserNames.Dock = DockStyle.Fill; List <string> lookup = new List <string>(); string[] firstSplit = textBoxUserNames.Text.Split(','); foreach (string s in firstSplit) { lookup.AddRange(s.Split(';')); } Dictionary <string, object> nameDict = new Dictionary <string, object>(); foreach (string name in lookup) { string cleanName = name.Trim(); if (cleanName.Length == 0) { continue; } if (!nameDict.ContainsKey(cleanName)) { nameDict.Add(cleanName, null); } } List <String> nameList = new List <string>(); foreach (string s in nameDict.Keys) { nameList.Add(s); } // start the resolve foreach (string name in nameList) { ListViewItemSubjectWrapper i = new ListViewItemSubjectWrapper(name); entryListView.Items.Add(i); } resolveAction = new AddRemoveSubjectsAction(pool, nameList, new List <Subject>()); resolveAction.NameResolveComplete += new AddRemoveSubjectsAction.NameResolvedEventHandler(resolveAction_NameResolveComplete); resolveAction.AllResolveComplete += new AddRemoveSubjectsAction.AllNamesResolvedEventHandler(resolveAction_AllResolveComplete); resolveAction.SubjectAddComplete += new AddRemoveSubjectsAction.SubjectAddedEventHandler(resolveAction_SubjectAddComplete); resolveAction.Completed += addAction_Completed; resolveAction.RunAsync(); }
private void ButtonRemove_Click(object sender, EventArgs e) { Program.AssertOnEventThread(); // Double check, this method is called from a context menu as well and the state could have changed under it if (!ButtonRemove.Enabled) { return; } List <Subject> subjectsToRemove = new List <Subject>(); foreach (AdSubjectRow r in GridViewSubjectList.SelectedRows) { subjectsToRemove.Add(r.subject); } var removeMessage = subjectsToRemove.Count == 1 ? string.Format(Messages.QUESTION_REMOVE_AD_USER_ONE, subjectsToRemove[0].DisplayName ?? subjectsToRemove[0].SubjectName) : string.Format(Messages.QUESTION_REMOVE_AD_USER_MANY, subjectsToRemove.Count); DialogResult questionDialog; using (var dlg = new ThreeButtonDialog( new ThreeButtonDialog.Details( null, removeMessage, Messages.AD_FEATURE_NAME), ThreeButtonDialog.ButtonYes, new ThreeButtonDialog.TBDButton(Messages.NO_BUTTON_CAPTION, DialogResult.No, ThreeButtonDialog.ButtonType.CANCEL, true))) { questionDialog = dlg.ShowDialog(this); } //CA-64818: DialogResult can be No if the No button has been hit //or Cancel if the dialog has been closed from the control box if (questionDialog != DialogResult.Yes) { return; } // Warn if user is revoking his currently-in-use credentials Session session = _connection.Session; if (session != null && session.SessionSubject != null) { foreach (Subject entry in subjectsToRemove) { if (entry.opaque_ref == session.SessionSubject) { string subjectName = entry.DisplayName ?? entry.SubjectName; if (subjectName == null) { subjectName = entry.subject_identifier; } else { subjectName = subjectName.Ellipsise(256); } string msg = string.Format(entry.IsGroup ? Messages.AD_CONFIRM_SUICIDE_GROUP : Messages.AD_CONFIRM_SUICIDE, subjectName, Helpers.GetName(_connection).Ellipsise(50)); DialogResult r; using (var dlg = new ThreeButtonDialog( new ThreeButtonDialog.Details( SystemIcons.Warning, msg, Messages.AD_FEATURE_NAME), ThreeButtonDialog.ButtonYes, new ThreeButtonDialog.TBDButton(Messages.NO_BUTTON_CAPTION, DialogResult.No, ThreeButtonDialog.ButtonType.CANCEL, true))) { r = dlg.ShowDialog(this); } //CA-64818: DialogResult can be No if the No button has been hit //or Cancel if the dialog has been closed from the control box if (r != DialogResult.Yes) { return; } break; } } } var action = new AddRemoveSubjectsAction(_connection, new List <string>(), subjectsToRemove); using (var dlog = new ActionProgressDialog(action, ProgressBarStyle.Continuous)) dlog.ShowDialog(this); }
private void ButtonRemove_Click(object sender, EventArgs e) { Program.AssertOnEventThread(); // Double check, this method is called from a context menu as well and the state could have changed under it if (!ButtonRemove.Enabled) { return; } var subjectsToRemove = GridViewSubjectList.SelectedRows.Cast <AdSubjectRow>().Select(r => r.subject).ToList(); if (subjectsToRemove.Count < 1) { return; } var removeMessage = subjectsToRemove.Count == 1 ? string.Format(Messages.QUESTION_REMOVE_AD_USER_ONE, subjectsToRemove[0].DisplayName ?? subjectsToRemove[0].SubjectName) : string.Format(Messages.QUESTION_REMOVE_AD_USER_MANY, subjectsToRemove.Count); string adminMessage = null; var conn = subjectsToRemove.FirstOrDefault(s => s.Connection != null)?.Connection; if (conn != null && Helpers.StockholmOrGreater(conn) && !conn.Cache.Hosts.Any(Host.RestrictPoolSecretRotation)) { var poolAdminsToRemove = (from Subject s in subjectsToRemove let roles = s.Connection.ResolveAll(s.roles) where roles.Any(r => r.name_label == Role.MR_ROLE_POOL_ADMIN) select s).ToList(); if (subjectsToRemove.Count == poolAdminsToRemove.Count) { adminMessage = poolAdminsToRemove.Count == 1 ? Messages.QUESTION_ADMIN_EXIT_PROCEDURE_ONE : Messages.QUESTION_ADMIN_EXIT_PROCEDURE_MANY; } else if (poolAdminsToRemove.Count > 0) { adminMessage = poolAdminsToRemove.Count == 1 ? Messages.QUESTION_ADMIN_EXIT_PROCEDURE_ONE_OF_MANY : string.Format(Messages.QUESTION_ADMIN_EXIT_PROCEDURE_SOME_OF_MANY, poolAdminsToRemove.Count); } if (!string.IsNullOrEmpty(adminMessage)) { removeMessage = string.Format("{0}\n\n{1} {2}", removeMessage, adminMessage, Messages.QUESTION_ADMIN_EXIT_PROCEDURE_ADVISORY); } } using (var dlg = new WarningDialog(removeMessage, ThreeButtonDialog.ButtonYes, new ThreeButtonDialog.TBDButton(Messages.NO_BUTTON_CAPTION, DialogResult.No, selected: true)) { WindowTitle = Messages.AD_FEATURE_NAME }) { //CA-64818: DialogResult can be No if the No button has been hit //or Cancel if the dialog has been closed from the control box if (dlg.ShowDialog(this) != DialogResult.Yes) { return; } } // Warn if user is revoking his currently-in-use credentials Session session = _connection.Session; if (session != null && session.SessionSubject != null) { foreach (Subject entry in subjectsToRemove) { if (entry.opaque_ref == session.SessionSubject) { string subjectName = entry.DisplayName ?? entry.SubjectName; if (subjectName == null) { subjectName = entry.subject_identifier; } else { subjectName = subjectName.Ellipsise(256); } string msg = string.Format(entry.IsGroup ? Messages.AD_CONFIRM_SUICIDE_GROUP : Messages.AD_CONFIRM_SUICIDE, subjectName, Helpers.GetName(_connection).Ellipsise(50)); DialogResult r; using (var dlg = new WarningDialog(msg, ThreeButtonDialog.ButtonYes, new ThreeButtonDialog.TBDButton(Messages.NO_BUTTON_CAPTION, DialogResult.No, selected: true)) { WindowTitle = Messages.AD_FEATURE_NAME }) { r = dlg.ShowDialog(this); } //CA-64818: DialogResult can be No if the No button has been hit //or Cancel if the dialog has been closed from the control box if (r != DialogResult.Yes) { return; } break; } } } var action = new AddRemoveSubjectsAction(_connection, new List <string>(), subjectsToRemove); using (var dlog = new ActionProgressDialog(action, ProgressBarStyle.Continuous)) dlog.ShowDialog(this); }