Exemple #1
0
 private void ConfigureConnectionBar(RdpOptions rdpOptions)
 {
     this.client.AdvancedSettings6.ConnectionBarShowMinimizeButton = false;
     this.client.AdvancedSettings6.ConnectionBarShowPinButton      = false;
     this.client.AdvancedSettings6.ConnectionBarShowRestoreButton  = false;
     this.client.AdvancedSettings3.DisplayConnectionBar            = rdpOptions.UserInterface.DisplayConnectionBar;
 }
        private static void ConfigureTsGateway(RdpOptions options, string newValue)
        {
            options.TsGateway.SeparateLogin = true;
            var guarded = new GuardedSecurity(persistence, options.TsGateway.Security);

            guarded.Domain = newValue;
        }
 private void FillRdpTimeOutControls(RdpOptions rdpOptions)
 {
     this.ShutdownTimeoutTextBox.Text    = rdpOptions.TimeOuts.ShutdownTimeout.ToString(CultureInfo.InvariantCulture);
     this.OverallTimeoutTextbox.Text     = rdpOptions.TimeOuts.OverallTimeout.ToString(CultureInfo.InvariantCulture);
     this.SingleTimeOutTextbox.Text      = rdpOptions.TimeOuts.ConnectionTimeout.ToString(CultureInfo.InvariantCulture);
     this.IdleTimeoutMinutesTextBox.Text = rdpOptions.TimeOuts.IdleTimeout.ToString(CultureInfo.InvariantCulture);
 }
 private void FillFavoriteRdpTimeOutOptions(RdpOptions rdpOptions)
 {
     rdpOptions.TimeOuts.ShutdownTimeout   = ParseInteger(this.ShutdownTimeoutTextBox);
     rdpOptions.TimeOuts.OverallTimeout    = ParseInteger(this.OverallTimeoutTextbox);
     rdpOptions.TimeOuts.ConnectionTimeout = ParseInteger(this.SingleTimeOutTextbox);
     rdpOptions.TimeOuts.IdleTimeout       = ParseInteger(this.IdleTimeoutMinutesTextBox);
 }
Exemple #5
0
        private void ConfigureSecurity(RdpOptions rdpOptions)
        {
            if (rdpOptions.Security.EnableTLSAuthentication)
            {
                this.client.AdvancedSettings5.AuthenticationLevel = 2;
            }

            this.nonScriptable.EnableCredSspSupport = rdpOptions.Security.EnableNLAAuthentication;

            var audioMode = (int)rdpOptions.Redirect.Sounds;

            this.client.SecuredSettings2.AudioRedirectionMode = (audioMode >= 0 && audioMode <= 2) ? audioMode : 0;

            IGuardedSecurity security = this.ResolveFavoriteCredentials();

            this.client.UserName = security.UserName;
            this.client.Domain   = security.Domain;
            try
            {
                if (!String.IsNullOrEmpty(security.Password))
                {
                    if (this.nonScriptable != null)
                    {
                        this.nonScriptable.ClearTextPassword = security.Password;
                    }
                }
            }
            catch (Exception exc)
            {
                Logging.Error("Error when trying to set the ClearTextPassword on the nonScriptable mstsc object", exc);
            }
        }
        private void FillTsGatewayControls(RdpOptions rdpOptions)
        {
            this.credentialsPanel1.LoadMRUs();
            TsGwOptions tsGateway = rdpOptions.TsGateway;

            this.ApplyUsageMethod(tsGateway.UsageMethod);
            this.txtTSGWServer.Text        = tsGateway.HostName;
            this.chkTSGWlogin.Checked      = tsGateway.SeparateLogin;
            this.credentialsPanel1.Enabled = tsGateway.SeparateLogin;

            if (tsGateway.SeparateLogin)
            {
                var guarded = this.CredentialFactory.CreateCredential(tsGateway.Security);
                this.credentialsPanel1.LoadFrom(guarded);
            }

            if (tsGateway.CredentialSource == 4)
            {
                this.cmbTSGWLogonMethod.SelectedIndex = 2;
            }
            else
            {
                this.cmbTSGWLogonMethod.SelectedIndex = tsGateway.CredentialSource;
            }
        }
Exemple #7
0
        private ISecurityOptions ResolveTransportGatewayCredentials(RdpOptions rdpOptions)
        {
            if (rdpOptions.TsGateway.SeparateLogin)
            {
                return(rdpOptions.TsGateway.Security);
            }

            return(this.Favorite.Security);
        }
Exemple #8
0
 private void ConfigureConnection(RdpOptions rdpOptions)
 {
     this.client.Server = this.Favorite.ServerName;
     this.client.AdvancedSettings3.RDPPort = this.Favorite.Port;
     this.client.AdvancedSettings3.ContainerHandledFullScreen = -1;
     // Use ConnectToServerConsole or ConnectToAdministerServer based on implementation
     this.client.AdvancedSettings7.ConnectToAdministerServer = rdpOptions.ConnectToConsole;
     this.client.AdvancedSettings3.ConnectToServerConsole    = rdpOptions.ConnectToConsole;
 }
Exemple #9
0
 private void ConfigureRedirectOptions(RdpOptions rdpOptions)
 {
     this.client.AdvancedSettings3.RedirectPorts      = rdpOptions.Redirect.Ports;
     this.client.AdvancedSettings3.RedirectPrinters   = rdpOptions.Redirect.Printers;
     this.client.AdvancedSettings3.RedirectSmartCards = rdpOptions.Redirect.SmartCards;
     this.client.AdvancedSettings3.PerformanceFlags   = rdpOptions.UserInterface.PerformanceFlags;
     this.client.AdvancedSettings6.RedirectClipboard  = rdpOptions.Redirect.Clipboard;
     this.client.AdvancedSettings6.RedirectDevices    = rdpOptions.Redirect.Devices;
 }
Exemple #10
0
        private void ConfigureInterface(RdpOptions rdpOptions)
        {
            //advanced settings
            //bool, 0 is false, other is true
            if (rdpOptions.UserInterface.AllowBackgroundInput)
            {
                this.client.AdvancedSettings.allowBackgroundInput = -1;
            }

            if (rdpOptions.UserInterface.BitmapPeristence)
            {
                this.client.AdvancedSettings.BitmapPeristence = -1;
            }

            if (rdpOptions.UserInterface.EnableCompression)
            {
                this.client.AdvancedSettings.Compress = -1;
            }

            if (rdpOptions.UserInterface.AcceleratorPassthrough)
            {
                this.client.AdvancedSettings2.AcceleratorPassthrough = -1;
            }

            if (rdpOptions.UserInterface.DisableControlAltDelete)
            {
                this.client.AdvancedSettings2.DisableCtrlAltDel = -1;
            }

            if (rdpOptions.UserInterface.DisplayConnectionBar)
            {
                this.client.AdvancedSettings2.DisplayConnectionBar = true;
            }

            if (rdpOptions.UserInterface.DoubleClickDetect)
            {
                this.client.AdvancedSettings2.DoubleClickDetect = -1;
            }

            if (rdpOptions.UserInterface.DisableWindowsKey)
            {
                this.client.AdvancedSettings2.EnableWindowsKey = -1;
            }

            if (rdpOptions.Security.EnableEncryption)
            {
                this.client.AdvancedSettings2.EncryptionEnabled = -1;
            }


            this.ConfigureAzureService(rdpOptions);
            this.ConfigureCustomReconnect();
        }
Exemple #11
0
        private void FillRdpDisplayControls(RdpOptions rdpOptions)
        {
            var userInterface = rdpOptions.UserInterface;

            this.chkDisableWallpaper.Checked             = userInterface.DisableWallPaper;
            this.chkDisableCursorBlinking.Checked        = userInterface.DisableCursorBlinking;
            this.chkDisableCursorShadow.Checked          = userInterface.DisableCursorShadow;
            this.chkDisableFullWindowDrag.Checked        = userInterface.DisableFullWindowDrag;
            this.chkDisableMenuAnimations.Checked        = userInterface.DisableMenuAnimations;
            this.chkDisableThemes.Checked                = userInterface.DisableTheming;
            this.AllowFontSmoothingCheckbox.Checked      = userInterface.EnableFontSmoothing;
            this.AllowDesktopCompositionCheckbox.Checked = userInterface.EnableDesktopComposition;
        }
Exemple #12
0
        private void FillFavoriteRdpDisplayOptions(RdpOptions rdpOptions)
        {
            var userInterface = rdpOptions.UserInterface;

            userInterface.DisableWallPaper         = this.chkDisableWallpaper.Checked;
            userInterface.DisableCursorBlinking    = this.chkDisableCursorBlinking.Checked;
            userInterface.DisableCursorShadow      = this.chkDisableCursorShadow.Checked;
            userInterface.DisableFullWindowDrag    = this.chkDisableFullWindowDrag.Checked;
            userInterface.DisableMenuAnimations    = this.chkDisableMenuAnimations.Checked;
            userInterface.DisableTheming           = this.chkDisableThemes.Checked;
            userInterface.EnableFontSmoothing      = this.AllowFontSmoothingCheckbox.Checked;
            userInterface.EnableDesktopComposition = this.AllowDesktopCompositionCheckbox.Checked;
        }
        private void FillRdpUserInterfaceControls(RdpOptions rdpOptions)
        {
            var userInterface = rdpOptions.UserInterface;

            this.GrabFocusOnConnectCheckbox.Checked      = rdpOptions.GrabFocusOnConnect;
            this.DisableWindowsKeyCheckbox.Checked       = userInterface.DisableWindowsKey;
            this.DetectDoubleClicksCheckbox.Checked      = userInterface.DoubleClickDetect;
            this.DisplayConnectionBarCheckbox.Checked    = userInterface.DisplayConnectionBar;
            this.DisableControlAltDeleteCheckbox.Checked = userInterface.DisableControlAltDelete;
            this.AcceleratorPassthroughCheckBox.Checked  = userInterface.AcceleratorPassthrough;
            this.EnableCompressionCheckbox.Checked       = userInterface.EnableCompression;
            this.EnableBitmapPersistenceCheckbox.Checked = userInterface.BitmapPeristence;
            this.AllowBackgroundInputCheckBox.Checked    = userInterface.AllowBackgroundInput;
            this.txtLoadBalanceInfo.Text = userInterface.LoadBalanceInfo;
        }
        private void FillFavoriteRdpInterfaceOptions(RdpOptions rdpOptions)
        {
            RdpUserInterfaceOptions userInterface = rdpOptions.UserInterface;

            rdpOptions.GrabFocusOnConnect         = this.GrabFocusOnConnectCheckbox.Checked;
            userInterface.DisableWindowsKey       = this.DisableWindowsKeyCheckbox.Checked;
            userInterface.DoubleClickDetect       = this.DetectDoubleClicksCheckbox.Checked;
            userInterface.DisplayConnectionBar    = this.DisplayConnectionBarCheckbox.Checked;
            userInterface.DisableControlAltDelete = this.DisableControlAltDeleteCheckbox.Checked;
            userInterface.AcceleratorPassthrough  = this.AcceleratorPassthroughCheckBox.Checked;
            userInterface.EnableCompression       = this.EnableCompressionCheckbox.Checked;
            userInterface.BitmapPeristence        = this.EnableBitmapPersistenceCheckbox.Checked;
            userInterface.AllowBackgroundInput    = this.AllowBackgroundInputCheckBox.Checked;
            userInterface.LoadBalanceInfo         = this.txtLoadBalanceInfo.Text;
        }
Exemple #15
0
        private void ConfigureTsGateway(RdpOptions rdpOptions)
        {
            // Terminal Server Gateway Settings
            this.client.TransportSettings.GatewayUsageMethod = (uint)rdpOptions.TsGateway.UsageMethod;
            this.client.TransportSettings.GatewayCredsSource = (uint)rdpOptions.TsGateway.CredentialSource;
            this.client.TransportSettings.GatewayHostname    = rdpOptions.TsGateway.HostName;
            var tsgwGuarded = this.CredentialFactory.CreateCredential(rdpOptions.TsGateway.Security);

            this.client.TransportSettings2.GatewayDomain             = tsgwGuarded.Domain;
            this.client.TransportSettings2.GatewayProfileUsageMethod = 1;
            var security             = this.ResolveTransportGatewayCredentials(rdpOptions);
            IGuardedSecurity guarded = this.CredentialFactory.CreateSecurityOptoins(security);

            this.client.TransportSettings2.GatewayUsername = guarded.UserName;
            this.client.TransportSettings2.GatewayPassword = guarded.Password;
        }
Exemple #16
0
        private void ConfigureStartBehaviour(RdpOptions rdpOptions)
        {
            this.client.AdvancedSettings2.GrabFocusOnConnect = rdpOptions.GrabFocusOnConnect;
            this.GrabInput = rdpOptions.GrabFocusOnConnect;

            if (rdpOptions.Security.Enabled)
            {
                if (rdpOptions.FullScreen)
                {
                    this.client.SecuredSettings2.FullScreen = -1;
                }

                this.client.SecuredSettings2.StartProgram = rdpOptions.Security.StartProgram;
                this.client.SecuredSettings2.WorkDir      = rdpOptions.Security.WorkingFolder;
            }
        }
Exemple #17
0
        /// <summary>
        /// The ActiveX component requires a UTF-8 encoded string, but .NET uses
        /// UTF-16 encoded strings by default.  The following code converts
        /// the UTF-16 encoded string so that the byte-representation of the
        /// LoadBalanceInfo string object will "appear" as UTF-8 to the Active component.
        /// Furthermore, since the final string still has to be shoehorned into
        /// a UTF-16 encoded string, I pad an extra space in case the number of
        /// bytes would be odd, in order to prevent the byte conversion from
        /// mangling the string at the end.  The space is ignored by the RDP
        /// protocol as long as it is inserted at the end.
        /// Finally, it is required that the LoadBalanceInfo setting is postfixed
        /// with \r\n in order to work properly.  Note also that \r\n MUST be
        /// the last two characters, so the space padding has to be inserted first.
        /// The following code has been tested with Windows Azure connections
        /// only - I am aware there are other types of RDP connections that
        /// require the LoadBalanceInfo parameter which I have not tested
        /// (e.g., Multi-Server Terminal Services Gateway), that may or may not
        /// work properly.
        ///
        /// Sources:
        ///  1. http://stackoverflow.com/questions/13536267/how-to-connect-to-azure-vm-with-remote-desktop-activex
        ///  2. http://social.technet.microsoft.com/Forums/windowsserver/en-US/e68d4e9a-1c8a-4e55-83b3-e3b726ff5346/issue-with-using-advancedsettings2loadbalanceinfo
        ///  3. Manual comparison of raw packets between Windows RDP client and Terminals using WireShark.
        /// </summary>
        private void ConfigureAzureService(RdpOptions rdpOptions)
        {
            if (!String.IsNullOrEmpty(rdpOptions.UserInterface.LoadBalanceInfo))
            {
                var lbTemp = rdpOptions.UserInterface.LoadBalanceInfo;

                if (lbTemp.Length % 2 == 1)
                {
                    lbTemp += " ";
                }

                lbTemp += "\r\n";
                byte[] bytes   = Encoding.UTF8.GetBytes(lbTemp);
                string lbFinal = Encoding.Unicode.GetString(bytes);
                this.client.AdvancedSettings2.LoadBalanceInfo = lbFinal;
            }
        }
Exemple #18
0
        private void ConfigureTimeouts(RdpOptions rdpOptions)
        {
            try
            {
                this.client.AdvancedSettings2.MinutesToIdleTimeout = rdpOptions.TimeOuts.IdleTimeout;

                int timeout = rdpOptions.TimeOuts.OverallTimeout;
                if (timeout > 600)
                {
                    timeout = 10;
                }
                if (timeout <= 0)
                {
                    timeout = 10;
                }
                this.client.AdvancedSettings2.overallConnectionTimeout = timeout;
                timeout = rdpOptions.TimeOuts.ConnectionTimeout;
                if (timeout > 600)
                {
                    timeout = 10;
                }
                if (timeout <= 0)
                {
                    timeout = 10;
                }

                this.client.AdvancedSettings2.singleConnectionTimeout = timeout;

                timeout = rdpOptions.TimeOuts.ShutdownTimeout;
                if (timeout > 600)
                {
                    timeout = 10;
                }
                if (timeout <= 0)
                {
                    timeout = 10;
                }
                this.client.AdvancedSettings2.shutdownTimeout = timeout;
            }
            catch (Exception exc)
            {
                Logging.Error("Error when trying to set timeout values.", exc);
            }
        }
Exemple #19
0
 private void ConfigureRedirectedDrives(RdpOptions rdpOptions)
 {
     if (rdpOptions.Redirect.Drives.Count > 0 && rdpOptions.Redirect.Drives[0].Equals("true"))
     {
         this.client.AdvancedSettings2.RedirectDrives = true;
     }
     else
     {
         for (int i = 0; i < this.nonScriptable.DriveCollection.DriveCount; i++)
         {
             IMsRdpDrive drive = this.nonScriptable.DriveCollection.get_DriveByIndex((uint)i);
             foreach (string str in rdpOptions.Redirect.Drives)
             {
                 if (drive.Name.IndexOf(str) > -1)
                 {
                     drive.RedirectionState = true;
                 }
             }
         }
     }
 }
        private void FillFavoriteTSgatewayOptions(RdpOptions rdpOptions)
        {
            this.credentialsPanel1.SaveMRUs();
            TsGwOptions tsgwOptions = rdpOptions.TsGateway;

            tsgwOptions.HostName = this.txtTSGWServer.Text;
            var guarded = this.CredentialFactory.CreateCredential(tsgwOptions.Security);

            this.credentialsPanel1.SaveTo(guarded);
            tsgwOptions.SeparateLogin    = this.chkTSGWlogin.Checked;
            tsgwOptions.CredentialSource = this.cmbTSGWLogonMethod.SelectedIndex;
            if (tsgwOptions.CredentialSource == 2)
            {
                tsgwOptions.CredentialSource = 4;
            }

            if (this.radTSGWenable.Checked)
            {
                if (this.chkTSGWlocalBypass.Checked)
                {
                    tsgwOptions.UsageMethod = 2;
                }
                else
                {
                    tsgwOptions.UsageMethod = 1;
                }
            }
            else
            {
                if (this.chkTSGWlocalBypass.Checked)
                {
                    tsgwOptions.UsageMethod = 4;
                }
                else
                {
                    tsgwOptions.UsageMethod = 0;
                }
            }
        }
        private static string GetDomain(RdpOptions options)
        {
            var guarded = new GuardedSecurity(persistence, options.TsGateway.Security);

            return(guarded.Domain);
        }
 private static void SetWorkingFolder(RdpOptions options, string newValue)
 {
     // we have to enable the security, otherwise the save method skips the nested properties
     options.Security.Enabled       = true;
     options.Security.WorkingFolder = newValue;
 }