private AsyncAction.SudoElevationResult GetElevatedSession(List <Role> allowedRoles, IXenConnection connection, string actionTitle) { AsyncAction.SudoElevationResult result = null; Program.Invoke(Program.MainWindow, () => { Form owner; try { //CA-337323: make an attempt to find the right owning form //most likely it will be the last one opened owner = Application.OpenForms.Cast <Form>().Last(); } catch { owner = Program.MainWindow; } using (var d = new RoleElevationDialog(connection, connection.Session, allowedRoles, actionTitle)) if (d.ShowDialog(owner) == DialogResult.OK) { result = new AsyncAction.SudoElevationResult(d.elevatedUsername, d.elevatedPassword, d.elevatedSession); } }); return(result); }
private AsyncAction.SudoElevationResult GetSudoElevationResult() { if (elevatedUsername == null) { return(null); } var ser = new AsyncAction.SudoElevationResult(elevatedUsername, elevatedPassword, elevatedSession); //use the session from the role elevation dialog, but only the first time elevatedSession = null; return(ser); }