Delphi/Rdp在连接前检查用户名和密码 [英] Delphi/Rdp check username and password before connect
问题描述
正如主题所说,我试图在delphi中使用此代码连接到服务器
as the subject say am trying to connect to server using this code in delphi
procedure TmainF.Button1Click(Sender: TObject);
var
rdp1 : TMsRdpClient7NotSafeForScripting ;
begin
rdp1 := TMsRdpClient7NotSafeForScripting.Create(self);
rdp1.Parent := mainF;
rdp1.Server:=server_name;
rdp1.UserName := user.Text;
rdp1.AdvancedSettings7.ClearTextPassword := password.Text;
rdp1.ConnectingText := 'connecting';
rdp1.DisconnectedText := 'disconnected';
rdp1.AdvancedSettings7.AuthenticationLevel:=0;
rdp1.AdvancedSettings7.EnableCredSspSupport:=true;
rdp1.Connect;
end;
代码工作正常,但是如果用户输入了错误的用户名或密码
rdp对象显示远程桌面登录提示框,以重新输入用户名或密码(如图片)
the code is working fine but if the user entered a wrong user name or password
the rdp object is showing the remote desktop login prompt box to reenter the user name or password like the image
我想在连接之前验证用户名和密码
或阻止此框并显示我的应用中的自定义消息
I want to validate the username and password before connect
or prevent this box and show a custom message from my app
我尝试使用OnLogonError()过程,但未触发任何代码
我读了这个问题但代码是c#,我与.getocx()混淆,在(MSTSCLib_TLB.pas)中找不到(PromptForCredentials)
I tried to use OnLogonError() procedure but it's not fired any code
and I read this Question but the code is c# and I confused with .getocx() and I can't find (PromptForCredentials) in (MSTSCLib_TLB.pas)
任何帮助:( ??
对不起,我的英语不好.
sorry for my bad English.
推荐答案
有一个接口 IMsRdpClientNonScriptable5
具有以下方法:
There is an interface IMsRdpClientNonScriptable5
that has the following methods:
-
Get_AllowPromptingForCredentials()
-
Set_AllowPromptingForCredentials()
如果在参数设置为 false
的情况下调用 Set_AllowPromptingForCredentials()
,则不会出现该对话框.
If you call Set_AllowPromptingForCredentials()
with the parameter set to false
the dialog won't appear.
关于如何获取此接口的实例-简便,您只需转换RDP客户端对象的 ControlInterface
:
As for how to get an instance of this interface - easy, you just cast the ControlInterface
of your RDP client object:
Ircns5 := rdp1.ControlInterface as IMsRdpClientNonScriptable5;
if Assigned(Ircns5) then
Ircns5.Set_AllowPromptingForCredentials(False);
这篇关于Delphi/Rdp在连接前检查用户名和密码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!