private void lnkSetCredentials_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            var prov      = _service.CurrentConnection.FeatureService.GetFeatureProvider(_fs.Provider);
            var connProps = new List <string>();

            foreach (var p in prov.ConnectionProperties)
            {
                if (!p.Enumerable)
                {
                    connProps.Add(p.Name);
                }
            }
            using (var diag = new SetCredentialsDialog(connProps.ToArray()))
            {
                if (diag.ShowDialog() == DialogResult.OK)
                {
                    _fs.SetConnectionProperty(diag.UserProperty, StringConstants.MgUsernamePlaceholder);
                    _fs.SetConnectionProperty(diag.PasswordProperty, StringConstants.MgPasswordPlaceholder);
                    _fs.SetEncryptedCredentials(_service.CurrentConnection, diag.Username, diag.Password);
                    _service.SyncSessionCopy();
                    InitGrid();
                    resDataCtrl.Init(_service);
                }
            }
        }
Beispiel #2
0
        private void WriteEncryptedCredentials()
        {
            string username = txtUsername.Text;
            string password = txtPassword.Text;

            if (!string.IsNullOrEmpty(username) && !string.IsNullOrEmpty(password))
            {
                if (username != StringConstants.MgUsernamePlaceholder && password != StringConstants.MgPasswordPlaceholder)
                {
                    if (_bChangedUsername || _bChangedPassword)
                    {
                        _fs.SetConnectionProperty("Username", StringConstants.MgUsernamePlaceholder); //NOXLATE
                        _fs.SetConnectionProperty("Password", StringConstants.MgPasswordPlaceholder); //NOXLATE
                        _fs.SetEncryptedCredentials(_service.CurrentConnection, username, password);
                        _service.SyncSessionCopy();
                    }
                }
            }
            else if (string.IsNullOrEmpty(username) && string.IsNullOrEmpty(password))
            {
                _fs.SetConnectionProperty("Username", null); //NOXLATE
                _fs.SetConnectionProperty("Password", null); //NOXLATE
                try
                {
                    _service.CurrentConnection.ResourceService.DeleteResourceData(_fs.ResourceID, StringConstants.MgUserCredentialsResourceData);
                }
                catch { }
                _service.SyncSessionCopy();
            }
        }
 private void btnApplyCredentials_Click(object sender, EventArgs e)
 {
     using (var diag = new CredentialsDialog())
     {
         if (diag.ShowDialog() == DialogResult.OK)
         {
             _fs.SetEncryptedCredentials(_service.CurrentConnection, diag.Username, diag.Password);
             resDataCtrl.RefreshList();
             OnResourceChanged();
             MessageBox.Show(Strings.CredentialsApplied);
         }
     }
 }