views:

308

answers:

3

I am hosting the IMsRdpClient6 ActiveX control in my WinForms application in order to make connections to remote machines.

I have setup a terminal services gateway machine, and I can successfully use it.

I want to get my ActiveX control to use this gateway. I have set the Gateway options, but connection fails with no error that I can see. Here is the code that I am using:

        MSTSCLib6.IMsRdpClient6 client6 = RdpClient.GetOcx() as MSTSCLib6.IMsRdpClient6;            

        if (client6 != null)
        {
            MSTSCLib6.IMsRdpClientTransportSettings2 transport = client6.TransportSettings2;

            if (Convert.ToBoolean(transport.GatewayIsSupported) == true)
            {
                client6.TransportSettings.GatewayHostname = "mygateway";
                client6.TransportSettings.GatewayUsageMethod = 2;

                client6.TransportSettings.GatewayCredsSource = 0;
                client6.TransportSettings.GatewayUserSelectedCredsSource = 0;
                client6.TransportSettings2.GatewayDomain = "mydomain";
                client6.TransportSettings2.GatewayPassword = "mypassword";
                client6.TransportSettings2.GatewayUsername = "myusername";
            }
        }
A: 

The answer to this was to omit the GatewayUserSelectedCredsSource and to include GatewayProfileUsageMethod = 1;

        MSTSCLib6.IMsRdpClient6 client6 = RdpClient.GetOcx() as MSTSCLib6.IMsRdpClient6;            

        if (client6 != null)
        {
            MSTSCLib6.IMsRdpClientTransportSettings2 transport = client6.TransportSettings2;

            if (Convert.ToBoolean(transport.GatewayIsSupported) == true)
            {
                client6.TransportSettings.GatewayHostname = "mygateway";
                client6.TransportSettings.GatewayUsageMethod = 1;

                client6.TransportSettings.GatewayCredsSource = 0;
                client6.TransportSettings.GatewayProfileUsageMethod = 1;
                client6.TransportSettings2.GatewayDomain = "mydomain";
                client6.TransportSettings2.GatewayPassword = "mypassword";
                client6.TransportSettings2.GatewayUsername = "myusername";
            }
        }
esac
A: 

It is possible to do this with the ActiveX embedded on a web page?

Rafael Luna
A: 

Just tried adding this code and got a field not valid error. I'm guessing it has something to do with not setting the server name, but it is not set in you example. Can you explain how to get around this.

regards Andrew. Will post code if needed.