访问远程桌面
Accessing Remote Desktop
我正在尝试在 C# 中以编程方式打开远程桌面会话。我找到了 this 教程,并按照它进行了操作。我有一个只包含一个名为 rdp
的 AxMSTSCLib.AxMsRdpClient8NotSafeForScripting
的表单,然后我有以下代码:
public RDPViewer()
{
InitializeComponent();
rdp.Server = "localhost";
rdp.UserName = "<userName>";
IMsTscNonScriptable secured = (IMsTscNonScriptable)rdp.GetOcx();
secured.ClearTextPassword = "<password>";
rdp.Connect();
}
(用户名和密码目前是硬编码的,这只是第一次测试,看看它是如何工作的)
当我尝试 运行 它时,我收到一个错误弹出窗口:
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,然后重新启动,但我已经这样做了并且仍然得到错误。
我已经进行了设置,因此可以通过 RDP 连接到本地主机,并且我可以使用与传入代码时相同的凭据使用远程桌面连接进行连接。
我终于找到问题了。原来它是在组策略中设置的,而不是在注册表中。我找到了答案 here - 相关的组策略设置是 "Require use of specific security layer for remote (RDP) connections",位于 Computer Configuration\Administrative Templates\Windows Components\Remote Desktop Services\Remote Desktop Session Host\Security
。
通过将该策略中的安全层选项从 SSL (TLS 1.0) 更改为 RDP,我能够连接。
这对我有用,无需更改远程计算机的设置:
rdpClient.AdvancedSettings9.EnableCredSspSupport = true;
请参阅:启用凭据安全支持提供程序进行身份验证:https://technet.microsoft.com/en-us/library/ff393716(v=ws.10).aspx
我正在尝试在 C# 中以编程方式打开远程桌面会话。我找到了 this 教程,并按照它进行了操作。我有一个只包含一个名为 rdp
的 AxMSTSCLib.AxMsRdpClient8NotSafeForScripting
的表单,然后我有以下代码:
public RDPViewer()
{
InitializeComponent();
rdp.Server = "localhost";
rdp.UserName = "<userName>";
IMsTscNonScriptable secured = (IMsTscNonScriptable)rdp.GetOcx();
secured.ClearTextPassword = "<password>";
rdp.Connect();
}
(用户名和密码目前是硬编码的,这只是第一次测试,看看它是如何工作的)
当我尝试 运行 它时,我收到一个错误弹出窗口:
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,然后重新启动,但我已经这样做了并且仍然得到错误。
我已经进行了设置,因此可以通过 RDP 连接到本地主机,并且我可以使用与传入代码时相同的凭据使用远程桌面连接进行连接。
我终于找到问题了。原来它是在组策略中设置的,而不是在注册表中。我找到了答案 here - 相关的组策略设置是 "Require use of specific security layer for remote (RDP) connections",位于 Computer Configuration\Administrative Templates\Windows Components\Remote Desktop Services\Remote Desktop Session Host\Security
。
通过将该策略中的安全层选项从 SSL (TLS 1.0) 更改为 RDP,我能够连接。
这对我有用,无需更改远程计算机的设置:
rdpClient.AdvancedSettings9.EnableCredSspSupport = true;
请参阅:启用凭据安全支持提供程序进行身份验证:https://technet.microsoft.com/en-us/library/ff393716(v=ws.10).aspx