访问远程桌面 [英] Accessing Remote Desktop

查看:86
本文介绍了访问远程桌面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在 C# 中以编程方式打开远程桌面会话.我发现 this 教程,并遵循它.我有一个表单,它只包含一个名为 rdpAxMSTSCLib.AxMsRdpClient8NotSafeForScripting,然后我有以下代码:

I'm trying to open up a remote desktop session programmatically in C#. I found this tutorial, and followed it. I have a form that just consists of a AxMSTSCLib.AxMsRdpClient8NotSafeForScripting called rdp, and then I have the following code:

    public RDPViewer()
    {
        InitializeComponent();
        rdp.Server = "localhost";
        rdp.UserName = "<userName>";

        IMsTscNonScriptable secured = (IMsTscNonScriptable)rdp.GetOcx();
        secured.ClearTextPassword = "<password>";
        rdp.Connect();
    }

(用户名和密码暂时是硬编码的,这只是第一次测试它是如何工作的)

(Username and password are hardcoded for now, this was just a first test to see how it worked)

然而,当我尝试运行它时,我收到一个错误弹出窗口:

When I try to run it, though, I get an error popup:

连接无法继续,因为未启用身份验证,并且远程计算机要求启用身份验证才能连接.

The connection cannot proceed because authentication is not enabled and the remote computer requires that authentication be enabled to connect.

谷歌搜索这个错误发现有几个站点指出这个错误的解决方案是去HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Terminal Server\WinStations\RDP-Tcp并设置SecurityLayer"值到 0,然后重新启动,但我已经这样做了,但仍然出现错误.

Googling this error finds several sites stating that the solution to this error is to go to HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Terminal Server\WinStations\RDP-Tcp and set the "SecurityLayer" value to 0, then reboot, but I've done this and still get the error.

我已经进行了设置,因此可以将 RDP 连接到本地主机,并且我可以使用远程桌面连接进行连接,使用的凭据与我在代码中传递的凭据相同.

I have already set things up so it's possible to RDP to localhost, and I can connect using Remote Desktop Connection using the same credentials as I'm passing in the code.

推荐答案

我最终发现了问题.原来它是在组策略中设置的,而不是在注册表中.我在这里找到了答案-相关的组策略设置是需要为远程 (RDP) 连接使用特定安全层",位于 Computer Configuration\Administrative Templates\Windows Components\Remote Desktop Services\Remote Desktop Session Host\Security.

I found the problem in the end. Turns out it was set in Group Policy, rather than in the registry. I found the answer here - The relevant Group Policy setting is "Require use of specific security layer for remote (RDP) connections", and is found at Computer Configuration\Administrative Templates\Windows Components\Remote Desktop Services\Remote Desktop Session Host\Security.

通过将该策略中的安全层选项从 SSL (TLS 1.0) 更改为 RDP,我能够连接.

By changing the Security Layer option in that policy from SSL (TLS 1.0) to RDP, I was able to connect.

这篇关于访问远程桌面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆