Exemple #1
0
        private void buttonJoinLeave_Click(object sender, EventArgs e)
        {
            Program.AssertOnEventThread();
            if (buttonJoinLeave.Text == Messages.AD_JOIN_DOMAIN)
            {
                // We're enabling AD            
                // Obtain domain, username and password

                joinPrompt.ShowDialog(this);
                // Blocking for a long time, check we haven't had the dialog disposed under us
                if (Disposing || IsDisposed)
                    return;

                if (joinPrompt.DialogResult == DialogResult.Cancel)
                {
                    joinPrompt.ClearPassword();
                    return;
                }

                EnableAdAction action = new EnableAdAction(pool, joinPrompt.Domain, joinPrompt.Username, joinPrompt.Password);
                if (pool.name_label.Length > 0)
                    action.Pool = pool;
                else
                    action.Host = Helpers.GetMaster(pool.Connection);
                action.RunAsync();
                joinPrompt.ClearPassword();
            }
            else
            {
                // We're disabling AD

                // Warn if the user will boot himself out by disabling AD
                Session session = pool.Connection.Session;
                if (session == null)
                    return;

                if (session.IsLocalSuperuser)
                {
                    // User is authenticated using local root account. Confirm anyway.
                    string msg = string.Format(Messages.AD_LEAVE_CONFIRM,
                                Helpers.GetName(pool).Ellipsise(50).EscapeAmpersands(), Domain);

                    DialogResult r = new ThreeButtonDialog(
                        new ThreeButtonDialog.Details(
                            null,
                            msg,
                            Messages.AD_FEATURE_NAME),
                        ThreeButtonDialog.ButtonYes,
                        new ThreeButtonDialog.TBDButton(Messages.NO_BUTTON_CAPTION, DialogResult.No, ThreeButtonDialog.ButtonType.CANCEL, true)).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;
                }
                else
                {
                    // Warn user will be booted out.
                    string msg = string.Format(pool.name_label.Length > 0 ? Messages.AD_LEAVE_WARNING : Messages.AD_LEAVE_WARNING_HOST,
                                Helpers.GetName(pool).Ellipsise(50), Domain);

                    DialogResult r = new ThreeButtonDialog(
                        new ThreeButtonDialog.Details(SystemIcons.Warning, msg, Messages.ACTIVE_DIRECTORY_TAB_TITLE),
                        ThreeButtonDialog.ButtonYes,
                        new ThreeButtonDialog.TBDButton(Messages.NO_BUTTON_CAPTION, DialogResult.No, ThreeButtonDialog.ButtonType.CANCEL, true)).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;
                }


                Host master = Helpers.GetMaster(pool.Connection);
                if (master == null)
                {
                    // Really shouldn't happen unless we have been very slow with the cache
                    log.Error("Could not retrieve master when trying to look up domain..");
                    throw new Exception(Messages.CONNECTION_IO_EXCEPTION);
                }
                AdPasswordPrompt passPrompt = new AdPasswordPrompt(false, master.external_auth_service_name);
                DialogResult result = passPrompt.ShowDialog(Program.MainWindow);
                if (result == DialogResult.Cancel)
                    return;

                Dictionary<string, string> creds = new Dictionary<string, string>();
                if (result != DialogResult.Ignore)
                {
                    creds.Add(DisableAdAction.KEY_USER, passPrompt.Username);
                    creds.Add(DisableAdAction.KEY_PASSWORD, passPrompt.Password);
                }
                DisableAdAction action = new DisableAdAction(pool, creds);
                if (pool.name_label.Length > 0)
                    action.Pool = pool;
                else
                    action.Host = Helpers.GetMaster(pool.Connection);
                action.RunAsync();
            }
        }
        public static PoolAbstractAction.AdUserAndPassword GetAdPrompt(Host poolMaster)
        {
            AdPasswordPrompt adPrompt = new AdPasswordPrompt(true, poolMaster.external_auth_service_name);

            Program.Invoke(Program.MainWindow, delegate
                                                   {
                                                       if (adPrompt.ShowDialog(Program.MainWindow) == DialogResult.Cancel)
                                                           throw new CancelledException();
                                                   });
            return new PoolAbstractAction.AdUserAndPassword(adPrompt.Username, adPrompt.Password);
        }
Exemple #3
0
 public AdPage()
 {
     InitializeComponent();
     Pool_CollectionChangedWithInvoke = Program.ProgramInvokeHandler(Pool_CollectionChanged);
     ColumnSubject.CellTemplate = new KeyValuePairCell();
     tTipLogoutButton.SetToolTip(Messages.AD_CANNOT_MODIFY_ROOT);
     tTipRemoveButton.SetToolTip(Messages.AD_CANNOT_MODIFY_ROOT);
     ConnectionsManager.History.CollectionChanged += new CollectionChangeEventHandler(History_CollectionChanged);
     Text = Messages.ACTIVE_DIRECTORY_TAB_TITLE;
     joinPrompt = new AdPasswordPrompt(true, null);
 }