private void SetCredentials()
{
try
{
if (((int)Force & (int)ConnectionInfo.Force.NoCredentials) == (int)ConnectionInfo.Force.NoCredentials)
{
return ;
}
string _user = _Info.Username;
string _pass = _Info.Password;
string _dom = _Info.Domain;
if (string.IsNullOrEmpty(_user))
{
if (Settings.Default.EmptyCredentials == "windows")
{
_ICAClient.Username = Environment.UserName;
}
else if (Settings.Default.EmptyCredentials == "custom")
{
_ICAClient.Username = Settings.Default.DefaultUsername;
}
}
else
{
_ICAClient.Username = _user;
}
if (string.IsNullOrEmpty(_pass))
{
if (Settings.Default.EmptyCredentials == "custom")
{
if (Settings.Default.DefaultPassword != "")
{
var cryptographyProvider = new LegacyRijndaelCryptographyProvider();
_ICAClient.SetProp("ClearPassword", cryptographyProvider.Decrypt(Settings.Default.DefaultPassword, Runtime.EncryptionKey));
}
}
}
else
{
_ICAClient.SetProp("ClearPassword", _pass);
}
if (string.IsNullOrEmpty(_dom))
{
if (Settings.Default.EmptyCredentials == "windows")
{
_ICAClient.Domain = Environment.UserDomainName;
}
else if (Settings.Default.EmptyCredentials == "custom")
{
_ICAClient.Domain = Settings.Default.DefaultDomain;
}
}
else
{
_ICAClient.Domain = _dom;
}
}
catch (Exception ex)
{
Runtime.MessageCollector.AddMessage(Messages.MessageClass.ErrorMsg, Language.strIcaSetCredentialsFailed + Environment.NewLine + ex.Message, true);
}
}