如何将终端服务网关与 IMsRdpClient6 ActiveX 控件一起使用?
我在 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
答案是省略 GatewayUserSelectedCredsSource 并包含 GatewayProfileUsageMethod = 1;
The answer to this was to omit the GatewayUserSelectedCredsSource and to include GatewayProfileUsageMethod = 1;
是否可以通过嵌入网页上的 ActiveX 来实现此目的?
It is possible to do this with the ActiveX embedded on a web page?
刚刚尝试添加此代码并收到字段无效错误。 我猜这与未设置服务器名称有关,但在您的示例中未设置。 你能解释一下如何解决这个问题吗?
问候安德鲁。 如果需要的话会发布代码。
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.