C#使用RDP的远程桌面应用程序。如何生成证书?
我在使用MSTSCLib从一台电脑连接到另一台电脑时遇到一些问题 它与服务器一起工作,但不与普通工作站一起工作C#使用RDP的远程桌面应用程序。如何生成证书?,c#,rdp,C#,Rdp,我在使用MSTSCLib从一台电脑连接到另一台电脑时遇到一些问题 它与服务器一起工作,但不与普通工作站一起工作 private void btn_connect_Click(object sender, EventArgs e) { try { rdp_control.Server = tbx_servername.Text; rdp_control.Connect(); ta
private void btn_connect_Click(object sender, EventArgs e)
{
try
{
rdp_control.Server = tbx_servername.Text;
rdp_control.Connect();
tabPage1.Text = "Connected";
}
catch (Exception exp)
{
MessageBox.Show(exp.ToString());
}
}
private void btn_disconnect_Click(object sender, EventArgs e)
{
if (rdp_control.Connected.ToString() == "1")
{
rdp_control.Disconnect();
}
}
客户端和服务器应用程序都位于同一NAT下的同一网络中。问题是证书,。。。我需要找到一种方法来包含证书。在Windows的普通远程桌面上,你会看到一个消息框,上面有一个问题:“你想使用这个证书吗….blablabla”,但这不是c#中的RDP函数
有什么想法吗?
谢谢B.R.下面的代码显示了一个简单的RDP客户端和服务器 RDP服务器
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using RDPCOMAPILib;
using AxMSTSCLib;
using System.Runtime.InteropServices;
namespace TCP_to_RDP_Converter
{
public partial class Form1 : Form
{
public static RDPSession currentSession = null;
public static void createSession()
{
currentSession = new RDPSession();
}
public static void Connect(RDPSession session)
{
session.OnAttendeeConnected += Incoming;
session.Open();
}
public static void Disconnect(RDPSession session)
{
session.Close();
}
public static string getConnectionString(RDPSession session, String authString,
string group, string password, int clientLimit)
{
IRDPSRAPIInvitation invitation =
session.Invitations.CreateInvitation
(authString, group, password, clientLimit);
return invitation.ConnectionString;
}
private static void Incoming(object Guest)
{
IRDPSRAPIAttendee MyGuest = (IRDPSRAPIAttendee)Guest;
MyGuest.ControlLevel = CTRL_LEVEL.CTRL_LEVEL_INTERACTIVE;
}
/// <summary>
/// Handle the form items
/// </summary>
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
createSession();
Connect(currentSession);
textConnectionString.Text = getConnectionString(currentSession,
"Test","Group","",5);
}
private void button2_Click(object sender, EventArgs e)
{
Disconnect(currentSession);
}
}
}
通过将RDP查看器类组件导入主窗体,可以添加对AxRDPCOMAPILib的引用
完整的项目可以从这里下载[下载]:下面的代码显示了一个简单的RDP客户端和服务器 RDP服务器
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using RDPCOMAPILib;
using AxMSTSCLib;
using System.Runtime.InteropServices;
namespace TCP_to_RDP_Converter
{
public partial class Form1 : Form
{
public static RDPSession currentSession = null;
public static void createSession()
{
currentSession = new RDPSession();
}
public static void Connect(RDPSession session)
{
session.OnAttendeeConnected += Incoming;
session.Open();
}
public static void Disconnect(RDPSession session)
{
session.Close();
}
public static string getConnectionString(RDPSession session, String authString,
string group, string password, int clientLimit)
{
IRDPSRAPIInvitation invitation =
session.Invitations.CreateInvitation
(authString, group, password, clientLimit);
return invitation.ConnectionString;
}
private static void Incoming(object Guest)
{
IRDPSRAPIAttendee MyGuest = (IRDPSRAPIAttendee)Guest;
MyGuest.ControlLevel = CTRL_LEVEL.CTRL_LEVEL_INTERACTIVE;
}
/// <summary>
/// Handle the form items
/// </summary>
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
createSession();
Connect(currentSession);
textConnectionString.Text = getConnectionString(currentSession,
"Test","Group","",5);
}
private void button2_Click(object sender, EventArgs e)
{
Disconnect(currentSession);
}
}
}
通过将RDP查看器类组件导入主窗体,可以添加对AxRDPCOMAPILib的引用
完整项目可从此处下载[下载]:使用此
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using MSTSCLib;
namespace RemoteTool
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
MSTerminalServiceControl1.Server = textBox1.Text;
MSTerminalServiceControl1.UserName = textBox2.Text;
IMsTscNonScriptable secured = (IMsTscNonScriptable)MSTerminalServiceControl1.GetOcx();
secured.ClearTextPassword = textBox3.Text;
MSTerminalServiceControl1.Connect();
}
private void button2_Click(object sender, EventArgs e)
{
MSTerminalServiceControl1.Disconnect();
}
}
}
使用这个
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using MSTSCLib;
namespace RemoteTool
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
MSTerminalServiceControl1.Server = textBox1.Text;
MSTerminalServiceControl1.UserName = textBox2.Text;
IMsTscNonScriptable secured = (IMsTscNonScriptable)MSTerminalServiceControl1.GetOcx();
secured.ClearTextPassword = textBox3.Text;
MSTerminalServiceControl1.Connect();
}
private void button2_Click(object sender, EventArgs e)
{
MSTerminalServiceControl1.Disconnect();
}
}
}
rdp\U控件的类型是什么?我假设您看过这篇文章()?对不起,忘了,它的“Microsoft终端服务客户端控制-版本1”我想冒昧地猜测这不是代码中的问题,而是windows防火墙和客户端上远程桌面的配置方式的问题。也许可以看看标准的远程桌面客户端,看看您是否可以在过度使用此代码之前进行连接。只是一个想法!高,也许我必须改变防火墙上的一些东西,我会检查。但是我可以连接到普通的远程桌面:)@drw\w我已经看过这篇文章了。PS:防火墙关闭,无更改什么是
rdp\U控制类型
?我假设您看过这篇文章()?对不起,忘了,它的“Microsoft终端服务客户端控制-版本1”我想冒昧地猜测这不是代码中的问题,而是windows防火墙和客户端上远程桌面的配置方式的问题。也许可以看看标准的远程桌面客户端,看看您是否可以在过度使用此代码之前进行连接。只是一个想法!高,也许我必须改变防火墙上的一些东西,我会检查。但是我可以连接到普通的远程桌面:)@drw\w我已经看过这篇文章了。PS:防火墙关闭,同一网络中没有变化。问题是证书,。。。我需要找到一种方法来包含证书。使用Windows的普通远程桌面,您会看到一个消息框,其中有一个问题:“是否要使用此证书…blablabla”但c中的RDP函数没有提供此功能#等等,我将附加一个使用连接字符串连接的简单RDP客户机-服务器应用程序。然后您就可以在这里自动生成证书了。。我使用RDPCOMPLIB和AxRDPCOMAPILib代替MSTSCLib。据我所知,这是最新的。这意味着。。。。如果两个连接在不同网络上的用户无法在此代码上使用RDP,则其位于同一网络中。问题是证书,。。。我需要找到一种方法来包含证书。使用Windows的普通远程桌面,您会看到一个消息框,其中有一个问题:“是否要使用此证书…blablabla”但c中的RDP函数没有提供此功能#等等,我将附加一个使用连接字符串连接的简单RDP客户机-服务器应用程序。然后您就可以在这里自动生成证书了。。我使用RDPCOMPLIB和AxRDPCOMAPILib代替MSTSCLib。据我所知,这是最新的。这意味着。。。。如果两个连接在不同网络上的用户无法在此代码上使用RDP?