Exemplo n.º 1
0
        private void SetCredentials()
        {
            try
            {
                if (((int)Force & (int)Connection.ConnectionInfo.Force.NoCredentials) == (int)Connection.ConnectionInfo.Force.NoCredentials)
                {
                    return;
                }

                string _user = this._Info.Username;
                string _pass = this._Info.Password;
                string _dom  = this._Info.Domain;

                if (string.IsNullOrEmpty(_user))
                {
                    if ((string)mRemoteNG.Settings.Default.EmptyCredentials == "windows")
                    {
                        _ICAClient.Username = Environment.UserName;
                    }
                    else if ((string)mRemoteNG.Settings.Default.EmptyCredentials == "custom")
                    {
                        _ICAClient.Username = mRemoteNG.Settings.Default.DefaultUsername;
                    }
                }
                else
                {
                    _ICAClient.Username = _user;
                }

                if (string.IsNullOrEmpty(_pass))
                {
                    if ((string)mRemoteNG.Settings.Default.EmptyCredentials == "custom")
                    {
                        if (mRemoteNG.Settings.Default.DefaultPassword != "")
                        {
                            var cryptographyProvider = new LegacyRijndaelCryptographyProvider();
                            _ICAClient.SetProp("ClearPassword", cryptographyProvider.Decrypt(Settings.Default.DefaultPassword, GeneralAppInfo.EncryptionKey));
                        }
                    }
                }
                else
                {
                    _ICAClient.SetProp("ClearPassword", _pass);
                }

                if (string.IsNullOrEmpty(_dom))
                {
                    if ((string)mRemoteNG.Settings.Default.EmptyCredentials == "windows")
                    {
                        _ICAClient.Domain = Environment.UserDomainName;
                    }
                    else if ((string)mRemoteNG.Settings.Default.EmptyCredentials == "custom")
                    {
                        _ICAClient.Domain = mRemoteNG.Settings.Default.DefaultDomain;
                    }
                }
                else
                {
                    _ICAClient.Domain = _dom;
                }
            }
            catch (Exception ex)
            {
                Runtime.MessageCollector.AddMessage(Messages.MessageClass.ErrorMsg, Language.strIcaSetCredentialsFailed + Environment.NewLine + ex.Message, true);
            }
        }
Exemplo n.º 2
0
        private void SetCredentials()
        {
            try
            {
                if (Force.HasFlag(ConnectionInfo.Force.NoCredentials))
                {
                    return;
                }

                var user = _info?.Username ?? "";
                var pass = _info?.Password ?? "";
                var 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(MessageClass.ErrorMsg,
                                                    Language.strIcaSetCredentialsFailed + Environment.NewLine +
                                                    ex.Message, true);
            }
        }
Exemplo n.º 3
0
        private void SetCredentials()
        {
            try
            {
                if (Force.HasFlag(ConnectionInfo.Force.NoCredentials))
                {
                    return;
                }

                var user = _info?.Username ?? "";
                var pass = _info?.Password ?? "";
                var dom  = _info?.Domain ?? "";

                if (string.IsNullOrEmpty(user))
                {
                    if (Settings.Default.EmptyCredentials == "windows")
                    {
                        user = Environment.UserName;
                    }
                    else if (Settings.Default.EmptyCredentials == "custom" || Settings.Default.EmptyCredentials == "admpwd")
                    {
                        user = Settings.Default.DefaultUsername;
                    }
                }
                if (string.IsNullOrEmpty(dom))
                {
                    if (Settings.Default.EmptyCredentials == "windows")
                    {
                        dom = Environment.UserDomainName;
                    }
                    else if (Settings.Default.EmptyCredentials == "custom" || Settings.Default.EmptyCredentials == "admpwd")
                    {
                        dom = Settings.Default.DefaultDomain;
                    }
                }
                _icaClient.Username = user;
                _icaClient.Domain   = dom;

                if (string.IsNullOrEmpty(pass))
                {
                    if (Settings.Default.EmptyCredentials == "custom")
                    {
                        if (Settings.Default.DefaultPassword != "")
                        {
                            var cryptographyProvider = new LegacyRijndaelCryptographyProvider();
                            pass = cryptographyProvider.Decrypt(Settings.Default.DefaultPassword, Runtime.EncryptionKey);
                        }
                    }
                    if (Settings.Default.EmptyCredentials == "admpwd")
                    {
                        if (dom == ".")
                        {
                            pass = AdmPwd.PDSUtils.PdsWrapper.GetLocalAdminPassword(null, _info.Hostname, false, false).Password;
                        }
                        else
                        {
                            pass = AdmPwd.PDSUtils.PdsWrapper.GetManagedAccountPassword(dom, user, false).Password;
                        }
                    }
                }

                _icaClient.SetProp("ClearPassword", pass);
            }
            catch (Exception ex)
            {
                Runtime.MessageCollector.AddMessage(MessageClass.ErrorMsg, Language.strIcaSetCredentialsFailed + Environment.NewLine + ex.Message, true);
            }
        }
Exemplo n.º 4
0
        public override bool Connect()
        {
            try
            {
                iIcaClient = new AxICAClient();
                ((Control)iIcaClient).DragEnter += new DragEventHandler(ICAConnection_DragEnter);
                ((Control)iIcaClient).DragDrop  += new DragEventHandler(ICAConnection_DragDrop);
                iIcaClient.OnDisconnect         += new EventHandler(iIcaClient_OnDisconnect);
                iIcaClient.Dock = DockStyle.Fill;


                Controls.Add(iIcaClient);

                IGuardedSecurity resolved = this.ResolveFavoriteCredentials();

                //rd.SendSpecialKeys(VncSharp.SpecialKeys);
                iIcaClient.Parent = this.Parent;
                iIcaClient.Dock   = DockStyle.Fill;

                iIcaClient.Address = Favorite.ServerName;
                switch (Favorite.Display.Colors)
                {
                case Colors.Bit16:
                    iIcaClient.SetProp("DesiredColor", "16");
                    break;

                case Colors.Bits32:
                    iIcaClient.SetProp("DesiredColor", "32");
                    break;

                case Colors.Bits8:
                    iIcaClient.SetProp("DesiredColor", "16");
                    break;

                default:
                    iIcaClient.SetProp("DesiredColor", "24");
                    break;
                }
                //             iIcaClient.Application = "Terminals " + Program.TerminalsVersion.ToString();

                // This line causes the following misleading error.
                // To log on to this remote computer, you must have Terminal Server User Access permissions on this computer.
                // By default, members of the Remote Desktop Users group have these permissions. If you are not a member of the
                // Remote Desktop Users group or another group that has these permissions, or if the Remote Desktop User group
                // does not have these permissions, you must be granted these permissions manually."

                ICAOptions icaOptions = this.Favorite.ProtocolProperties as ICAOptions;
                iIcaClient.AppsrvIni   = icaOptions.ServerINI;
                iIcaClient.WfclientIni = icaOptions.ClientINI;
                iIcaClient.Encrypt     = icaOptions.EnableEncryption;
                string encryptLevel   = "Encrypt";
                string specifiedLevel = icaOptions.EncryptionLevel.Trim();
                if (specifiedLevel.Contains(" "))
                {
                    encryptLevel = specifiedLevel.Substring(0, specifiedLevel.IndexOf(" ")).Trim();
                    if (encryptLevel != "")
                    {
                        iIcaClient.EncryptionLevelSession = encryptLevel;
                    }
                }



                iIcaClient.Domain   = resolved.Domain;
                iIcaClient.Address  = Favorite.ServerName;
                iIcaClient.Username = resolved.UserName;
                iIcaClient.SetProp("ClearPassword", resolved.Password);
                if (icaOptions.ApplicationName != "")
                {
                    iIcaClient.ConnectionEntry = icaOptions.ApplicationName;
                    iIcaClient.InitialProgram  = icaOptions.ApplicationName;
                    iIcaClient.Application     = icaOptions.ApplicationPath;
                    iIcaClient.WorkDirectory   = icaOptions.ApplicationWorkingFolder;
                }


                Text = "Connecting to ICA Server...";

                iIcaClient.Visible = true;

                iIcaClient.SetProp("ScalingMode", "3");
                iIcaClient.Launch          = false;
                iIcaClient.TransportDriver = "TCP/IP";
                iIcaClient.Connect();
                iIcaClient.Focus();


                return(true);
            }
            catch (Exception exc)
            {
                Logging.Fatal("Connecting to ICA", exc);
                return(false);
            }
        }
Exemplo n.º 5
0
        public override bool Connect()
        {
            try
            {
                iIcaClient = new AxICAClient();
                ((Control)iIcaClient).DragEnter += new DragEventHandler(ICAConnection_DragEnter);
                ((Control)iIcaClient).DragDrop += new DragEventHandler(ICAConnection_DragDrop);
                iIcaClient.OnDisconnect += new EventHandler(iIcaClient_OnDisconnect);
                iIcaClient.Dock = DockStyle.Fill;

                Controls.Add(iIcaClient);

                ISecurityOptions security = this.Favorite.Security.GetResolvedCredentials();

                //rd.SendSpecialKeys(VncSharp.SpecialKeys);
                iIcaClient.Parent = this.Parent;
                iIcaClient.Dock = DockStyle.Fill;

                iIcaClient.Address = Favorite.ServerName;
                switch (Favorite.Display.Colors)
                {
                    case Colors.Bit16:
                        iIcaClient.SetProp("DesiredColor", "16");
                        break;
                    case Colors.Bits32:
                        iIcaClient.SetProp("DesiredColor", "32");
                        break;
                    case Colors.Bits8:
                        iIcaClient.SetProp("DesiredColor", "16");
                        break;
                    default:
                        iIcaClient.SetProp("DesiredColor", "24");
                        break;

                }
                //             iIcaClient.Application = "Terminals " + Program.TerminalsVersion.ToString();

                // This line causes the following misleading error.
                // To log on to this remote computer, you must have Terminal Server User Access permissions on this computer.
                // By default, members of the Remote Desktop Users group have these permissions. If you are not a member of the
                // Remote Desktop Users group or another group that has these permissions, or if the Remote Desktop User group
                // does not have these permissions, you must be granted these permissions manually."

                ICAOptions icaOptions = this.Favorite.ProtocolProperties as ICAOptions;
                iIcaClient.AppsrvIni = icaOptions.ServerINI;
                iIcaClient.WfclientIni = icaOptions.ClientINI;
                iIcaClient.Encrypt = icaOptions.EnableEncryption;
                string encryptLevel = "Encrypt";
                string specifiedLevel = icaOptions.EncryptionLevel.Trim();
                if (specifiedLevel.Contains(" "))
                {
                    encryptLevel = specifiedLevel.Substring(0, specifiedLevel.IndexOf(" ")).Trim();
                    if (encryptLevel != "") iIcaClient.EncryptionLevelSession = encryptLevel;
                }

                iIcaClient.Domain = security.Domain;
                iIcaClient.Address = Favorite.ServerName;
                iIcaClient.Username = security.UserName;
                iIcaClient.SetProp("ClearPassword", security.Password);
                if (icaOptions.ApplicationName != "")
                {
                    iIcaClient.ConnectionEntry = icaOptions.ApplicationName;
                    iIcaClient.InitialProgram = icaOptions.ApplicationName;
                    iIcaClient.Application = icaOptions.ApplicationPath;
                    iIcaClient.WorkDirectory = icaOptions.ApplicationWorkingFolder;
                }

                Text = "Connecting to ICA Server...";

                iIcaClient.Visible = true;

                iIcaClient.SetProp("ScalingMode", "3");
                iIcaClient.Launch = false;
                iIcaClient.TransportDriver = "TCP/IP";
                iIcaClient.Connect();
                iIcaClient.Focus();

                return true;
            }
            catch (Exception exc)
            {
                Logging.Fatal("Connecting to ICA", exc);
                return false;
            }
        }
Exemplo n.º 6
0
        private void SetCredentials()
        {
            try
            {
                string _user = (string)this.Info.Username;
                string _pass = (string)this.Info.Password;
                string _dom  = (string)this.Info.Domain;

                if (_user == "")
                {
                    if ((string)Settings.Default.EmptyCredentials == "windows")
                    {
                        ICA_Client.Username = Environment.UserName;
                    }
                    else if ((string)Settings.Default.EmptyCredentials == "custom")
                    {
                        ICA_Client.Username = Settings.Default.DefaultUsername;
                    }
                }
                else
                {
                    ICA_Client.Username = _user;
                }

                if (_pass == "")
                {
                    if ((string)Settings.Default.EmptyCredentials == "custom")
                    {
                        if (Settings.Default.DefaultPassword != "")
                        {
                            ICA_Client.SetProp("ClearPassword",
                                               Security.Crypt.Decrypt((string)Settings.Default.DefaultPassword,
                                                                      (string)
                                                                      mRemoteNC.AppInfo.General.EncryptionKey));
                        }
                    }
                }
                else
                {
                    ICA_Client.SetProp("ClearPassword", _pass);
                }

                if (_dom == "")
                {
                    if ((string)Settings.Default.EmptyCredentials == "windows")
                    {
                        ICA_Client.Domain = Environment.UserDomainName;
                    }
                    else if ((string)Settings.Default.EmptyCredentials == "custom")
                    {
                        ICA_Client.Domain = Settings.Default.DefaultDomain;
                    }
                }
                else
                {
                    ICA_Client.Domain = _dom;
                }
            }
            catch (Exception ex)
            {
                Runtime.MessageCollector.AddMessage(Messages.MessageClass.ErrorMsg,
                                                    Language.strIcaSetCredentialsFailed + Constants.vbNewLine +
                                                    ex.Message, true);
            }
        }