private static void GetServiceUserCredentials(ref bool useWindowsCredentials, ref string userName, ref string password, ref string domainName)
        {
            RegistryKey policyKey = Registry.CurrentUser.OpenSubKey(@"SOFTWARE\Policies\SmartAccess\SealSignSQSClient\Authentication", false);

            if (policyKey != null)
            {
                useWindowsCredentials = Convert.ToBoolean(policyKey.GetValue("UseWindowsCredential", false));
                if (!useWindowsCredentials)
                {
                    userName   = policyKey.GetValue("SealSignSQSUserName", "").ToString();
                    password   = policyKey.GetValue("SealSignSQSPassword", "").ToString();
                    domainName = policyKey.GetValue("SealSignSQSDomain", "").ToString();
                }
                else
                {
                    userName   = "";
                    password   = "";
                    domainName = "";
                }
                policyKey.Close();
            }
            else
            {
                RegistryKey userKey = Registry.CurrentUser.OpenSubKey(@"SOFTWARE\SmartAccess\SealSignSQSClient\Authentication", false);
                if (userKey != null)
                {
                    useWindowsCredentials = Convert.ToBoolean(userKey.GetValue("UseWindowsCredential", true));
                    if (!useWindowsCredentials)
                    {
                        userName   = userKey.GetValue("SealSignSQSUserName", "").ToString();
                        password   = CryptTools.Decrypt(userKey.GetValue("SealSignSQSPassword", "").ToString());
                        domainName = userKey.GetValue("SealSignSQSDomain", "").ToString();
                    }
                    else
                    {
                        userName   = "";
                        password   = "";
                        domainName = "";
                    }
                    userKey.Close();
                }
            }
        }
Example #2
0
        private void UserCredentialsForm_Load(object sender, EventArgs e)
        {
            RegistryKey policyKey = Registry.CurrentUser.OpenSubKey(@"SOFTWARE\Policies\SmartAccess\SealSignSQSClient\Authentication", false);

            if (policyKey != null)
            {
                chkUseWindowsCredential.Checked = Convert.ToBoolean(policyKey.GetValue("UseWindowsCredential", false));
                if (!chkUseWindowsCredential.Checked)
                {
                    txtUsername.Text = policyKey.GetValue("SealSignSQSUserName", "").ToString();
                    txtPassword.Text = policyKey.GetValue("SealSignSQSPassword", "").ToString();
                    txtDomain.Text   = policyKey.GetValue("SealSignSQSDomain", "").ToString();
                }
                txtUsername.Enabled             = false;
                txtPassword.Enabled             = false;
                txtDomain.Enabled               = false;
                chkUseWindowsCredential.Enabled = false;
                btnOK.Enabled = false;
                policyKey.Close();
            }
            else
            {
                RegistryKey userKey = Registry.CurrentUser.OpenSubKey(@"SOFTWARE\SmartAccess\SealSignSQSClient\Authentication", false);
                if (userKey != null)
                {
                    chkUseWindowsCredential.Checked = Convert.ToBoolean(userKey.GetValue("UseWindowsCredential", true));
                    if (!chkUseWindowsCredential.Checked)
                    {
                        txtUsername.Text = userKey.GetValue("SealSignSQSUserName", "").ToString();
                        txtPassword.Text = CryptTools.Decrypt(userKey.GetValue("SealSignSQSPassword", "").ToString());
                        txtDomain.Text   = userKey.GetValue("SealSignSQSDomain", "").ToString();
                    }
                    txtUsername.Enabled = !chkUseWindowsCredential.Checked;
                    txtPassword.Enabled = !chkUseWindowsCredential.Checked;
                    txtDomain.Enabled   = !chkUseWindowsCredential.Checked;
                    userKey.Close();
                }
            }
        }