예제 #1
0
        private void InitializeForm()
        {
            try
            {
                if (_tenant == null)
                {
                    cbAuthentication.Enabled       = false;
                    cbAuthentication.SelectedIndex = (int)AuthenticationMode.SharePointOnline;

                    btRemove.Enabled = false;

                    lbLastConnectionTime.Text = string.Format("{0} no data", LAST_CONNECTION_PREFIX);
                }
                else
                {
                    tbTenantAdminUrl.Text = _tenant.AdminUrlAsString;
                    tbUsername.Text       = _tenant.UserName;
                    tbPassword.Text       = _tenant.Password;

                    tbTenantAdminUrl.Enabled       = false;
                    cbAuthentication.Enabled       = false;
                    cbAuthentication.SelectedIndex = (int)AuthenticationMode.SharePointOnline;

                    if (tbUsername.Text.Length == 0)
                    {
                        cbUseCurrentUserCredentials.Checked = true;
                    }
                    else if (tbUsername.Text.Length > 0)
                    {
                        tbPassword.Select();
                    }

                    lbLastConnectionTime.Text = string.Format("{0} {1} {2}", LAST_CONNECTION_PREFIX, _tenant.LoadDate.ToLongDateString(), _tenant.LoadDate.ToShortTimeString());

                    // Try to retrieve credentials
                    string password;
                    if (CredManUtil.TryGetPassword(_tenant.AdminUrlAsString, out password, StorageType.Tenant))
                    {
                        tbPassword.Text            = password;
                        cbRememberPassword.Checked = true;
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, this.Text, MessageBoxButtons.OK, MessageBoxIcon.Error);
                LogUtil.LogException(ex);
            }
        }
예제 #2
0
        private void InitializeForm()
        {
            try
            {
                if (_site == null)
                {
                    cbAuthentication.SelectedIndex = (int)AuthenticationMode.Default;
                    lbLastConnectionTime.Text      = string.Format("{0} no data", LAST_CONNECTION_PREFIX);

                    btRemove.Enabled = false;
                }
                else
                {
                    tbSiteUrl.Enabled                   = false;
                    tbSiteUrl.Text                      = _site.UrlAsString;
                    cbAuthentication.Enabled            = false;
                    cbAuthentication.SelectedIndex      = (int)_site.Authentication;
                    cbUseCurrentUserCredentials.Checked = _site.UseCurrentCredentials;
                    tbUsername.Text                     = _site.UserName;
                    lbLastConnectionTime.Text           = string.Format("{0} {1} {2}", LAST_CONNECTION_PREFIX, _site.LoadDate.ToLongDateString(), _site.LoadDate.ToShortTimeString());

                    if (_site.UseCurrentCredentials)
                    {
                        tbUsername.Text = string.Empty;
                        tbPassword.Text = string.Empty;
                    }
                    else
                    {
                        // Try to retrieve credentials
                        string password;
                        if (CredManUtil.TryGetPassword(_site.UrlAsString, out password, StorageType.SiteCollection))
                        {
                            tbPassword.Text            = password;
                            cbRememberPassword.Checked = true;
                        }
                        else
                        {
                            tbPassword.Select();
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, this.Text, MessageBoxButtons.OK, MessageBoxIcon.Error);
                LogUtil.LogException(ex);
            }
        }
예제 #3
0
 private void SavePassword()
 {
     try
     {
         if (cbRememberPassword.Checked)
         {
             // Save credentials
             CredManUtil.SaveCredentials(tbSiteUrl.Text.Trim(), tbUsername.Text.Trim(), tbPassword.Text.Trim(), StorageType.SiteCollection);
         }
         else
         {
             // Delete credentials
             CredManUtil.DeleteCredentials(tbSiteUrl.Text.Trim(), StorageType.SiteCollection);
         }
     }
     catch (Exception ex)
     {
         ToggleButtons(true);
         MessageBox.Show(ex.Message, this.Text, MessageBoxButtons.OK, MessageBoxIcon.Error);
         LogUtil.LogException(ex);
     }
 }