How to use MSTSCLib to connect remote desktop using Gateway and C#

Joel Brecker 1 Reputation point
2022-02-07T16:06:57.343+00:00

We are trying to create a Windows Forms Application that will connect to RDS through a Gateway. How can this be achieved? We have tried the following:

rdp.Server = server;
            rdp.UserName = username;
            rdp.Domain = domainName;
            rdp.AdvancedSettings8.LoadBalanceInfo = "tsv://MS Terminal Services Plugin.1.OFSC_Primary_Col";
            rdp.TransportSettings3.GatewayHostname = gatewayHostname; //FQDN
            rdp.TransportSettings3.GatewayProfileUsageMethod = 1;
            rdp.TransportSettings3.GatewayCredsSource = 0;
            rdp.TransportSettings3.GatewayUsageMethod = 1;
            rdp.TransportSettings3.GatewayDomain = "ofsc";
            rdp.TransportSettings3.GatewayUsername = username;
            rdp.TransportSettings3.GatewayPassword = password;
            rdp.AdvancedSettings7.EnableCredSspSupport = true;
            rdp.AdvancedSettings8.NegotiateSecurityLayer = true;
            rdp.AdvancedSettings7.AuthenticationLevel = 0;

            rdp.ColorDepth = 16;
            rdp.DesktopWidth = 1024;
            rdp.DesktopHeight = 720;
            rdp.Connect();
Remote Desktop
Remote Desktop
A Microsoft app that connects remotely to computers and to virtual apps and desktops.
4,259 questions
C#
C#
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
10,306 questions
{count} votes