private void CheckAuthentication()
        {
            if (username.Length == 0 || api_access_key.Length == 0)
            {
                CredentialsDialog credentialsDialog = new CredentialsDialog();
                System.Windows.Forms.DialogResult dialogResult = credentialsDialog.ShowDialog(this);

                if (dialogResult != DialogResult.OK) return;

                if (dialogResult == DialogResult.OK)
                {
                    username = credentialsDialog.Username;
                    api_access_key = credentialsDialog.ApiAccessKey;
                    deleteAllContainersButton.Enabled = true;
                }

                try
                {
                    Connection = new Connection(new UserCredentials(username, api_access_key));
                    RetrieveContainers();
                }
                catch
                {
                    MessageBox.Show("Authentication failed");
                    Form1_Load(this, new EventArgs());
                }
            }
        }
Exemple #2
0
        private static NetworkCredential PromptImpl(IWin32Window owner, string realm, string path)
        {
            var credential = TryLoadFromFile(path);
            
            using (var dialog = new CredentialsDialog { Realm = realm })
            {
                if (credential != null)
                {
                    dialog.UserName = credential.UserName;
                    dialog.Password = credential.Password;
                    dialog.SavePassword = credential.Password.Length > 0;
                }

                if (dialog.ShowDialog(owner) != DialogResult.OK)
                    return null;

                if (dialog.UserName.Length == 0 || dialog.Password.Length == 0)
                    return null;

                credential = new NetworkCredential(dialog.UserName, dialog.Password);
                    
                if (dialog.SavePassword)
                {
                    Directory.CreateDirectory(Path.GetDirectoryName(path));
                    SaveToFile(path, credential);
                }
                else
                {
                    if (File.Exists(path))
                        File.Delete(path);
                }
            }

            return credential;
        }
Exemple #3
0
        private void setUserBtn_Click(object sender, EventArgs e)
        {
            CredentialsDialog dlg = new CredentialsDialog(EditorProperties.Resources.TaskSchedulerName);

            if (TargetServer != null)
            {
                dlg.Target = TargetServer;
            }
            if (dlg.ShowDialog(this) == DialogResult.OK)
            {
                SetUserText(dlg.UserName);
                string[] userParts = dlg.UserName.Split('\\');
                if (userParts.Length == 1)
                {
                    Domain = TargetServer;
                    User   = userParts[0];
                }
                else if (userParts.Length == 2)
                {
                    Domain = userParts[0];
                    User   = userParts[1];
                }
                Password = dlg.Password;
            }
        }
Exemple #4
0
 public static void CredentialsDialog(Form parentForm)
 {
     using (var credentialsDialog1 = new CredentialsDialog())
     {
         var res = credentialsDialog1.ShowDialog(parentForm);
         AddTestResult(null, "Run", $"{res}: {credentialsDialog1.UserName}:{credentialsDialog1.Password}");
     }
 }
Exemple #5
0
        private void HandleAuthenticationRequiredMessage(AuthenticationRequiredMessage msg)
        {
            var model = new CredentialsModel {
                PromptMessage = msg.Message
            };
            var credentialsDialog = new CredentialsDialog(model);
            var dialogResult      = credentialsDialog.ShowDialog();

            msg.Callback(dialogResult, model.UserName, model.Password);
        }
Exemple #6
0
        public void CredentialsDialogTest()
        {
            var cd = new CredentialsDialog("Caption", "Message", Environment.UserDomainName + "\\" + Environment.UserName);

            cd.EncryptPassword   = true;
            cd.ForcePreVistaUI   = true;
            cd.SaveChecked       = true;
            cd.ShowSaveCheckBox  = true;
            cd.Target            = "TestTarget";
            cd.ValidatePassword += CredDlgOnValidatePassword;
            cd.ShowDialog();
            Assert.That(MessageBox.Show("Confirm UI strings, old dlg and save chkbox", "Confirm", MessageBoxButtons.YesNo) == DialogResult.Yes);
            cd.ConfirmCredentials(false);

            cd.Reset();
            Assert.That(cd.Caption, Is.Null);
            Assert.That(cd.SaveChecked, Is.False);

            cd.Caption           = "Caption";
            cd.UserName          = "******";
            cd.ValidatePassword += CredentialsDialog.StandardPasswordValidator;
            cd.ShowDialog();
            Assert.That(MessageBox.Show("Confirm new dlg and no save chkbox", "Confirm", MessageBoxButtons.YesNo) == DialogResult.Yes);
            cd.ConfirmCredentials(true);

            CredentialsDialog.ParseUserName(cd.UserName, out string user, out string dom);

            void CredDlgOnValidatePassword(object sender, CredentialsDialog.PasswordValidatorEventArgs e)
            {
                Assert.That(ReferenceEquals(sender, cd));
                if (cd.EncryptPassword)
                {
                    Assert.That(e.Password, Is.Null);
                    Assert.That(e.SecurePassword, Is.Not.Null);
                }
                else
                {
                    Assert.That(e.Password, Is.Not.Null);
                    Assert.That(e.SecurePassword, Is.Null);
                }
            }
        }
Exemple #7
0
        internal static string InvokeCredentialDialog(string userName, IWin32Window owner)
        {
            CredentialsDialog dlg = new CredentialsDialog(EditorProperties.Resources.TaskSchedulerName,
                                                          EditorProperties.Resources.CredentialPromptMessage, userName);

            dlg.ValidatePassword = true;
            if (dlg.ShowDialog(owner) == DialogResult.OK)
            {
                return(dlg.Password);
            }
            return(null);
        }
        private string InvokeCredentialDialog(string userName)
        {
            CredentialsDialog dlg = new CredentialsDialog(EditorProperties.Resources.TaskSchedulerName,
                                                          EditorProperties.Resources.CredentialPromptMessage, userName);

            dlg.ValidatePassword = true;
            if (dlg.ShowDialog(ParentForm) == DialogResult.OK)
            {
                return(dlg.Password);
            }
            return(null);
        }
Exemple #9
0
        private bool Login()
        {
            using (CredentialsDialog dlgLogin = new CredentialsDialog())
            {
                dlgLogin.User    = Config.Get <string>("LastUser", string.Empty);
                dlgLogin.Caption = "CCOW Server";
                dlgLogin.Message = "Please provide an administrative user to access configuration settings.";
                while (true)
                {
                    if (dlgLogin.ShowDialog() == DialogResult.OK)
                    {
                        IntPtr token = IntPtr.Zero;

                        if (AuthenticationUtils.Login(dlgLogin.Domain, dlgLogin.User, dlgLogin.PasswordToString(), out token))
                        {
                            WindowsPrincipal principal = Thread.CurrentPrincipal as WindowsPrincipal;

                            if (AuthenticationUtils.IsAdmin(principal) || AuthenticationUtils.IsDomainAdmin(principal))
                            {
                                string saveUser = dlgLogin.User;

                                if (!string.IsNullOrEmpty(dlgLogin.Domain))
                                {
                                    saveUser = dlgLogin.Domain + "\\" + dlgLogin.User;
                                }

                                Config.Set <string>("LastUser", saveUser);
                                return(true);
                            }
                            else
                            {
                                MessageBox.Show(this, "User is not a member of Administrators group.", "Invalid User",
                                                MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                            }
                        }
                        else
                        {
                            Win32Exception e = new Win32Exception(Marshal.GetLastWin32Error());

                            MessageBox.Show(this, e.Message, "Authentication Error",
                                            MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                        }
                    }
                    else
                    {
                        break;
                    }
                }
            }
            return(false);
        }
        public bool RequestCredential(CredentialRequest request, out System.Net.NetworkCredential credential)
        {
            credential = null;

            var dialog = new CredentialsDialog(request);

            if (dialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                credential = dialog.GetCredential();
                return(true);
            }

            return(false);
        }
Exemple #11
0
 /// <summary>
 /// Gets the repository.
 /// </summary>
 /// <returns></returns>
 private XmlDocument GetRepository( )
 {
     try {
         XmlDocument    doc = new XmlDocument( );
         string         url = string.Format(URL_FORMAT, REPOSITORY);
         HttpWebRequest req = HttpWebRequest.Create(url) as HttpWebRequest;
         if (req.Proxy != null && ProxyCredentials != null)
         {
             req.Proxy.Credentials = ProxyCredentials;
         }
         req.UserAgent = string.Format(CultureInfo.InvariantCulture, Properties.Resources.UserAgent, this.GetType( ).Assembly.GetName( ).Version.ToString( ));
         using (HttpWebResponse resp = req.GetResponse( ) as HttpWebResponse) {
             using (Stream strm = resp.GetResponseStream( )) {
                 doc.Load(strm);
                 this.downloadProgress.SetValue(1);
             }
         }
         proxyRetryCount = 0;
         return(doc);
     } catch (WebException wex) {
         if (wex.Message.Contains(Properties.Resources.ProxyExceptionMessage) && proxyRetryCount < PROXY_RETRY_MAX)
         {
             //get credentials
             proxyRetryCount++;
             if (CredentialsDialog.ShowDialog(this.FindForm( ), true) == DialogResult.OK)
             {
                 if (string.IsNullOrEmpty(CredentialsDialog.Username) || string.IsNullOrEmpty(CredentialsDialog.Password))
                 {
                     throw;
                 }
                 else
                 {
                     ProxyCredentials = new NetworkCredential(CredentialsDialog.Username, CredentialsDialog.Password);
                 }
             }
             else
             {
                 throw;
             }
             return(GetRepository( ));
         }
         else
         {
             throw;
         }
     } catch (Exception ex) {
         throw;
     }
 }
Exemple #12
0
        /// <summary>
        /// Downloads the platform tools.
        /// </summary>
        /// <returns></returns>
        private string DownloadPlatformTools( )
        {
            string tempFile = string.Empty;

            try {
                XmlElement ele = Repository.DocumentElement.SelectSingleNode(PlatformXpath, this.NSManager) as XmlElement;
                if (ele == null)
                {
                    throw new ArgumentException(Properties.Resources.PlatformUrlNotFoundMessage);
                }
                int size = 0;
                int.TryParse(ele.SelectSingleNode("sdk:size", NSManager).InnerText, out size);
                string file = ele.SelectSingleNode("sdk:url", NSManager).InnerText;
                tempFile = Path.Combine(Path.GetTempPath( ), file);
                string toolsUrl = string.Format(URL_FORMAT, file);

                DownloadFile(toolsUrl, tempFile, size);
            } catch (WebException wex) {
                if (wex.Message.Contains(Properties.Resources.ProxyExceptionMessage) && proxyRetryCount < PROXY_RETRY_MAX)
                {
                    //get credentials
                    proxyRetryCount++;
                    if (CredentialsDialog.ShowDialog(this.FindForm( ), true) == DialogResult.OK)
                    {
                        if (string.IsNullOrEmpty(CredentialsDialog.Username) || string.IsNullOrEmpty(CredentialsDialog.Password))
                        {
                            throw;
                        }
                        else
                        {
                            ProxyCredentials = new NetworkCredential(CredentialsDialog.Username, CredentialsDialog.Password);
                        }
                    }
                    else
                    {
                        throw;
                    }
                    return(DownloadSdkTools( ));
                }
                else
                {
                    throw;
                }
            }
            proxyRetryCount = 0;
            return(tempFile);
        }
Exemple #13
0
        private void AddProfileCommand()
        {
            var profileViewModel = new ProfileViewModel();

            var dialog = new CredentialsDialog(profileViewModel)
            {
                Owner = OptionsView.CurrentInstance,
                WindowStartupLocation = WindowStartupLocation.CenterOwner
            };

            var result = dialog.ShowDialog();

            if (result == true)
            {
                Profiles.Add(profileViewModel);
            }
        }
Exemple #14
0
        private void Timewax_Load(object sender, RibbonUIEventArgs e)
        {
            bool hasCredentials = HasCredentials();

            if (!hasCredentials)
            {
                CredentialsDialog dialog = new CredentialsDialog(true);
                dialog.Controls["MainLabel"].Text = "Voordat je kan werken met de Timewax intergratie, \n moet je toegangsgegevens geven voor Timewax.";
                DialogResult result = dialog.ShowDialog();
            }

            Setup();

            SetupChangedRowListener();

            Globals.ThisWorkbook.Application.ScreenUpdating = true;
        }
Exemple #15
0
        public virtual void GetCredentials(IScheduledResource scheduledResource)
        {
            var cancelled = false;

            while ((String.IsNullOrEmpty(AccountName) || String.IsNullOrEmpty(Password)) && !cancelled)
            {
                CredentialsDialog credentialsDialog = new CredentialsDialog {
                    UserName = scheduledResource.UserName, Options = CredentialsDialogOptions.GenericCredentials, ValidatePassword = true
                };
                var dialogResult = credentialsDialog.ShowDialog();
                if (dialogResult == System.Windows.Forms.DialogResult.Cancel)
                {
                    cancelled = true;
                }
                AccountName = credentialsDialog.UserName;
                Password    = credentialsDialog.Password;
            }
        }
Exemple #16
0
        private void EditProfileCommand()
        {
            var tempProfile = JsonConvert.DeserializeObject <ProfileViewModel>(JsonConvert.SerializeObject(SelectedProfile));

            var dialog = new CredentialsDialog(tempProfile)
            {
                Owner = OptionsView.CurrentInstance,
                WindowStartupLocation = WindowStartupLocation.CenterOwner
            };

            var result = dialog.ShowDialog();

            if (result == true)
            {
                Profiles.Remove(SelectedProfile);
                Profiles.Add(tempProfile);
            }
        }
		private void setUserBtn_Click(object sender, EventArgs e)
		{
			CredentialsDialog dlg = new CredentialsDialog(EditorProperties.Resources.TaskSchedulerName);
			if (this.TargetServer != null)
				dlg.Target = this.TargetServer;
			if (dlg.ShowDialog(this) == System.Windows.Forms.DialogResult.OK)
			{
				SetUserText(dlg.UserName);
				string[] userParts = dlg.UserName.Split('\\');
				if (userParts.Length == 1)
				{
					this.Domain = this.TargetServer;
					this.User = userParts[0];
				}
				else if (userParts.Length == 2)
				{
					this.Domain = userParts[0];
					this.User = userParts[1];
				}
				this.Password = dlg.Password;
			}
		}
        private void cm_OnConnectToShare(object sender, EventArgs e)
        {
            WinError error = WinError.ERROR_SUCCESS;
            bool determinePath = true;
            bool initialConnect = false;
            bool showPathError = false;
            string username = null;
            string path = null;

            while (true)
            {
                if (determinePath)
                {
                    // Determine share path to connect to
                    ConnectToShareDialog connectDialog = new ConnectToShareDialog(path, showPathError);

                    if (connectDialog.ShowDialog() == DialogResult.OK)
                    {
                        showPathError = false;
                        determinePath = false;
                        path = connectDialog.GetPath();

                        if (connectDialog.UseAlternateUserCreds())
                        {
                            error = WinError.ERROR_ACCESS_DENIED;
                        }
                        else
                        {
                            initialConnect = true;
                        }
                    }
                    else
                    {
                        break;
                    }
                }

                if (initialConnect)
                {
                    Application.UseWaitCursor = true;
                    error = FileClient.FileClient.CreateConnection(path, null, null);
                    Application.UseWaitCursor = false;
                    initialConnect = false;
                }

                if (error == WinError.ERROR_SUCCESS)
                {
                    // Refresh RemoteShares list and exit
                    RemoteShares.Add(path);
                    break;
                }

                if (error == WinError.ERROR_BAD_NET_NAME)
                {
                    // Show share path connect dialog to allow the user to correct the bad path
                    //MessageBox.Show("The network path is unavailable", "File connection error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    showPathError = true;
                    determinePath = true;
                    continue;
                }

                if (error == WinError.ERROR_DOWNGRADE_DETECTED ||
                    error == WinError.ERROR_ACCESS_DENIED ||
                    error == WinError.ERROR_SESSION_CREDENTIAL_CONFLICT ||
                    error == WinError.ERROR_BAD_USERNAME ||
                    error == WinError.ERROR_INVALID_PASSWORD ||
                    error == WinError.ERROR_LOGON_TYPE_NOT_GRANTED)
                {
                    // Prompt for updated user credentials to access share
                    CredentialsDialog credDialog = new CredentialsDialog(username);

                    if (credDialog.ShowDialog() == DialogResult.OK)
                    {
                        if (credDialog.UseDefaultUserCreds())
                        {
                            initialConnect = true;
                            username = null;
                            continue;
                        }

                        username = credDialog.GetUsername();

                        Application.UseWaitCursor = true;
                        error = FileClient.FileClient.CreateConnection(path,
                                                                       username,
                                                                       credDialog.GetPassword());
                        Application.UseWaitCursor = false;
                        continue;
                    }
                    else
                    {
                        // Cancel Connect To attempt
                        break;
                    }
                }
                else
                {
                    // Encounter unexpected error
                    break;
                }
            }

            RefreshNetworkTreeNode();
            Application.UseWaitCursor = false;
        }
        private void cm_OnConnectToShare(object sender, EventArgs e)
        {
            WinError error          = WinError.ERROR_SUCCESS;
            bool     determinePath  = true;
            bool     initialConnect = false;
            bool     showPathError  = false;
            string   username       = null;
            string   path           = null;

            while (true)
            {
                if (determinePath)
                {
                    // Determine share path to connect to
                    ConnectToShareDialog connectDialog = new ConnectToShareDialog(path, showPathError);

                    if (connectDialog.ShowDialog() == DialogResult.OK)
                    {
                        showPathError = false;
                        determinePath = false;
                        path          = connectDialog.GetPath();

                        if (connectDialog.UseAlternateUserCreds())
                        {
                            error = WinError.ERROR_ACCESS_DENIED;
                        }
                        else
                        {
                            initialConnect = true;
                        }
                    }
                    else
                    {
                        break;
                    }
                }

                if (initialConnect)
                {
                    Application.UseWaitCursor = true;
                    error = FileClient.FileClient.CreateConnection(path, null, null);
                    Application.UseWaitCursor = false;
                    initialConnect            = false;
                }

                if (error == WinError.ERROR_SUCCESS)
                {
                    // Refresh RemoteShares list and exit
                    RemoteShares.Add(path);
                    break;
                }

                if (error == WinError.ERROR_BAD_NET_NAME)
                {
                    // Show share path connect dialog to allow the user to correct the bad path
                    //MessageBox.Show("The network path is unavailable", "File connection error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    showPathError = true;
                    determinePath = true;
                    continue;
                }

                if (error == WinError.ERROR_DOWNGRADE_DETECTED ||
                    error == WinError.ERROR_ACCESS_DENIED ||
                    error == WinError.ERROR_SESSION_CREDENTIAL_CONFLICT ||
                    error == WinError.ERROR_BAD_USERNAME ||
                    error == WinError.ERROR_INVALID_PASSWORD ||
                    error == WinError.ERROR_LOGON_TYPE_NOT_GRANTED)
                {
                    // Prompt for updated user credentials to access share
                    CredentialsDialog credDialog = new CredentialsDialog(username);

                    if (credDialog.ShowDialog() == DialogResult.OK)
                    {
                        if (credDialog.UseDefaultUserCreds())
                        {
                            initialConnect = true;
                            username       = null;
                            continue;
                        }

                        username = credDialog.GetUsername();

                        Application.UseWaitCursor = true;
                        error = FileClient.FileClient.CreateConnection(path,
                                                                       username,
                                                                       credDialog.GetPassword());
                        Application.UseWaitCursor = false;
                        continue;
                    }
                    else
                    {
                        // Cancel Connect To attempt
                        break;
                    }
                }
                else
                {
                    // Encounter unexpected error
                    break;
                }
            }

            RefreshNetworkTreeNode();
            Application.UseWaitCursor = false;
        }
 private void linkCreds_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
 {
     credsDialog = new CredentialsDialog(sUsername);
     credsDialog.ShowDialog(this);
 }
Exemple #21
0
        public UpdateProject OpenProject(string projectPath)
        {
            UpdateProject project;
            try
            {
                project = UpdateProject.LoadProject(projectPath);
            }
            catch (Exception ex)
            {
                Popup.ShowPopup(this, SystemIcons.Error, "Error while reading the project.", ex,
                    PopupButtons.Ok);
                return null;
            }

            if (!project.SaveCredentials)
            {
                var credentialsDialog = new CredentialsDialog();
                if (credentialsDialog.ShowDialog() == DialogResult.OK)
                {
                    try
                    {
                        _ftpPassword =
                            AesManager.Decrypt(Convert.FromBase64String(project.FtpPassword),
                                credentialsDialog.Password.Trim(), credentialsDialog.Username.Trim());

                        if (project.Proxy != null)
                            _proxyPassword =
                                AesManager.Decrypt(Convert.FromBase64String(project.ProxyPassword),
                                    credentialsDialog.Password.Trim(), credentialsDialog.Username.Trim());

                        if (project.UseStatistics)
                            _sqlPassword =
                                AesManager.Decrypt(Convert.FromBase64String(project.SqlPassword),
                                    credentialsDialog.Password.Trim(), credentialsDialog.Username.Trim());
                    }
                    catch (CryptographicException)
                    {
                        Popup.ShowPopup(this, SystemIcons.Error, "Invalid credentials.",
                            "The entered credentials are invalid.", PopupButtons.Ok);
                        return null;
                    }
                    catch (Exception ex)
                    {
                        Popup.ShowPopup(this, SystemIcons.Error, "The decryption progress has failed.",
                            ex, PopupButtons.Ok);
                        return null;
                    }
                }
                else
                {
                    return null;
                }

                if (project.FtpUsername == credentialsDialog.Username)
                    return project;

                Popup.ShowPopup(this, SystemIcons.Error, "Invalid credentials.",
                    "The entered credentials are invalid.", PopupButtons.Ok);
                return null;
            }

            try
            {
                _ftpPassword =
                    AesManager.Decrypt(Convert.FromBase64String(project.FtpPassword),
                        Program.AesKeyPassword, Program.AesIvPassword);

                if (project.Proxy != null)
                    _proxyPassword =
                        AesManager.Decrypt(Convert.FromBase64String(project.ProxyPassword),
                            Program.AesKeyPassword, Program.AesIvPassword);

                if (project.UseStatistics)
                    _sqlPassword =
                        AesManager.Decrypt(Convert.FromBase64String(project.SqlPassword),
                            Program.AesKeyPassword, Program.AesIvPassword);
            }
            catch (Exception ex)
            {
                Popup.ShowPopup(this, SystemIcons.Error, "The decryption progress has failed.",
                    ex, PopupButtons.Ok);
                return null;
            }

            return project;
        }
Exemple #22
0
        /// <summary>
        /// Method will be called when we try to connect to Host from the ADUC Plugin
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void cm_OnConnect(object sender, EventArgs e)
        {
            bool initialConnect          = true;
            SelectDomainDialog domainDlg = null;

            while (true)
            {
                if (initialConnect)
                {
                    domainDlg = new SelectDomainDialog(_hn.domainName, _hn.creds.UserName);
                    if (domainDlg.ShowDialog() == DialogResult.OK)
                    {
                        _hn.domainName           = domainDlg.GetDomain();
                        _hn.domainControllerName = domainDlg.GetDomainControllerName();

                        if (!domainDlg.UseDefaultUserCreds())
                        {
                            _hn.creds.UserName = domainDlg.GetUsername();
                            _hn.creds.Password = domainDlg.GetPassword();
                        }
                    }
                    else
                    {
                        if (!_hn.IsConnectionSuccess)
                        {
                            _hn.domainControllerName = _hn.domainName = _hn.creds.UserName = _hn.creds.Password = "";
                        }

                        break; // Connection dialog close on cancel
                    }
                }

                if (!ConnectToDomain())
                {
                    if (!domainDlg.UseDefaultUserCreds())
                    {
                        CredentialsDialog credsDialog = new CredentialsDialog(_hn.creds.UserName);
                        if (credsDialog.ShowDialog(domainDlg) == DialogResult.OK)
                        {
                            _hn.creds.UserName = credsDialog.GetUsername();
                            _hn.creds.Password = credsDialog.GetPassword();

                            initialConnect = false;
                            continue;
                        }
                        else
                        {
                            _hn.domainControllerName = _hn.domainName = _hn.creds.UserName = _hn.creds.Password = "";
                            break; // Connection dialog close on cancel
                        }
                    }
                    else
                    {
                        MessageBox.Show("Failed to connect to domain. Please use the alternate credentials",
                                        "Likewise Administrative Console", MessageBoxButtons.OKCancel, MessageBoxIcon.Exclamation);
                    }
                }
                else
                {
                    break;
                }
            }
        }
    /// <summary>
    /// Method will be called when we try to connect to Host from the ADUC Plugin
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    private void cm_OnConnect(object sender, EventArgs e)
    {
        bool initialConnect = true;
        SelectDomainDialog domainDlg = null;

        while (true)
        {
            if (initialConnect)
            {
                domainDlg = new SelectDomainDialog(_hn.domainName, _hn.creds.UserName);
                if (domainDlg.ShowDialog() == DialogResult.OK)
                {
                    _hn.domainName = domainDlg.GetDomain();
                    _hn.domainControllerName = domainDlg.GetDomainControllerName();

                    if (!domainDlg.UseDefaultUserCreds())
                    {
                        _hn.creds.UserName = domainDlg.GetUsername();
                        _hn.creds.Password = domainDlg.GetPassword();
                    }
                }
                else
                {
                    if (!_hn.IsConnectionSuccess)
                        _hn.domainControllerName = _hn.domainName = _hn.creds.UserName = _hn.creds.Password = "";

                    break; // Connection dialog close on cancel
                }
            }

            if (!ConnectToDomain())
            {
                if (!domainDlg.UseDefaultUserCreds())
                {
                    CredentialsDialog credsDialog = new CredentialsDialog(_hn.creds.UserName);
                    if (credsDialog.ShowDialog(domainDlg) == DialogResult.OK)
                    {
                        _hn.creds.UserName = credsDialog.GetUsername();
                        _hn.creds.Password = credsDialog.GetPassword();

                        initialConnect = false;
                        continue;
                    }
                    else
                    {
                        _hn.domainControllerName = _hn.domainName = _hn.creds.UserName = _hn.creds.Password = "";
                        break; // Connection dialog close on cancel
                    }
                }
                else
                {
                    MessageBox.Show("Failed to connect to domain. Please use the alternate credentials",
                                    "Likewise Administrative Console", MessageBoxButtons.OKCancel, MessageBoxIcon.Exclamation);
                }
            }
            else
            {
                break;
            }
        }
    }
		internal static string InvokeCredentialDialog(string userName, IWin32Window owner)
		{
			CredentialsDialog dlg = new CredentialsDialog(EditorProperties.Resources.TaskSchedulerName,
				EditorProperties.Resources.CredentialPromptMessage, userName);
			dlg.Options |= CredentialsDialogOptions.Persist;
			dlg.ValidatePassword = true;
			if (dlg.ShowDialog(owner) == DialogResult.OK)
				return dlg.Password;
			return null;
		}
Exemple #25
0
        public virtual void GetCredentials(IScheduledResource scheduledResource)
        {
            var cancelled = false;
            while((String.IsNullOrEmpty(AccountName) || String.IsNullOrEmpty(Password)) && !cancelled)
            {

                CredentialsDialog credentialsDialog = new CredentialsDialog { UserName = scheduledResource.UserName, Options = CredentialsDialogOptions.GenericCredentials, ValidatePassword = true };
                var dialogResult = credentialsDialog.ShowDialog();
                if(dialogResult == System.Windows.Forms.DialogResult.Cancel)
                {
                    cancelled = true;
                }
                AccountName = credentialsDialog.UserName;
                Password = credentialsDialog.Password;
            }
        }
		private string InvokeCredentialDialog(string userName)
		{
			CredentialsDialog dlg = new CredentialsDialog(EditorProperties.Resources.TaskSchedulerName,
				EditorProperties.Resources.CredentialPromptMessage, userName);
			dlg.Options |= CredentialsDialogOptions.Persist;
			dlg.ValidatePassword = true;
			if (dlg.ShowDialog(this.ParentForm) == DialogResult.OK)
				return dlg.Password;
			return null;
		}
Exemple #27
-1
        private void CheckAuthentication()
        {
            if (username.Length == 0 || api_access_key.Length == 0)
            {
                CredentialsDialog credentialsDialog = new CredentialsDialog();
                System.Windows.Forms.DialogResult dialogResult = credentialsDialog.ShowDialog(this);

                if (dialogResult != DialogResult.OK) return;

                if (dialogResult == DialogResult.OK)
                {
                    username = credentialsDialog.Username;
                    api_access_key = credentialsDialog.ApiAccessKey;
                    auth_endpoint = credentialsDialog.AuthEndpoint;

                    if (auth_endpoint.Length == 0)
                    {
                        auth_endpoint = "https://auth.api.rackspacecloud.com/v1.0";
                    }
                    deleteAllContainersButton.Enabled = true;

                }

                try
                {
                    Connection = new Connection(new UserCredentials(new System.Uri(auth_endpoint),username, api_access_key, null, null));
                    RetrieveContainers();
                }
                catch
                {
                    MessageBox.Show("Authentication failed");
                    Form1_Load(this, new EventArgs());
                }
            }
        }