如何将终端服务网关与 IMsRdpClient6 ActiveX 控件一起使用?

发布于 2024-07-26 00:48:18 字数 1051 浏览 9 评论 0原文

我在 WinForms 应用程序中托管 IMsRdpClient6 ActiveX 控件,以便连接到远程计算机。

我已经设置了终端服务网关机器,并且可以成功使用它。

我想让我的 ActiveX 控件使用此网关。 我已设置网关选项,但连接失败,但没有看到任何错误。 这是我正在使用的代码:

        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";
            }
        }

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";
            }
        }

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

舂唻埖巳落 2024-08-02 00:48:18

答案是省略 GatewayUserSelectedCredsSource 并包含 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";
            }
        }

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";
            }
        }
旧城烟雨 2024-08-02 00:48:18

是否可以通过嵌入网页上的 ActiveX 来实现此目的?

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

岁月如刀 2024-08-02 00:48:18

刚刚尝试添加此代码并收到字段无效错误。 我猜这与未设置服务器名称有关,但在您的示例中未设置。 你能解释一下如何解决这个问题吗?

问候安德鲁。 如果需要的话会发布代码。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文