简体   繁体   English

如何识别 RDP/MSTSC 登录失败的时间?

[英]How to recognize when logon fails in RDP / MSTSC?

I am working on a C# implementation of RDP / MSTSC using the MsRdpClient9NotSafeForScripting class .我正在使用 MsRdpClient9NotSafeForScripting class 研究 RDP / MSTSC 的C# 实现

I need to recognize when the user logon failed due to wrong credentials.我需要识别用户登录因错误凭据而失败的时间。

The event OnLogonError should do the job but it doesn't fire (at least not on Server 2016), while the other events seem to work properly.事件OnLogonError应该可以完成这项工作,但它不会触发(至少在 Server 2016 上不会),而其他事件似乎可以正常工作。

From the Microsoft documentation of OnLogonError :来自OnLogonError的 Microsoft 文档:

LOGON_FAILED_BAD_PASSWORD (0 (0x0)) LOGON_FAILED_BAD_PASSWORD (0 (0x0))

The logon failed because the logon credentials are not valid.登录失败,因为登录凭据无效。

The behaviour (not fireing OnLogonError) is reported several times, but without solution.多次报告该行为(未触发 OnLogonError),但没有解决方案。 The once hint I found is: at codeproject :我发现的一次提示是: 在 codeproject

After further testing, I found out that if connecting to a Windows 2003 server, the event is entered.经过进一步测试,我发现如果连接到Windows 2003服务器,则进入事件。 But not when connecting to Win7 and newer and Win2008R2 and newer.但连接到 Win7 及更高版本和 Win2008R2 及更高版本时不会。 I wonder if Microsoft removed the event functionality in newer systems?我想知道微软是否在较新的系统中删除了事件功能?

But from the documentation of the event it should be supported但是从事件的文档来看,它应该得到支持

Minimum supported client Windows Vista支持的最低客户端 Windows Vista

Minimum supported server Windows Server 2008最低支持服务器 Windows 服务器 2008


Edit编辑

I downloaded mRemoteNG , which seems to be a very clean implementation of RDP.我下载了mRemoteNG ,这似乎是一个非常干净的 RDP 实现。 The event is not used there.那里不使用该事件。 But when I add it, it also never fires.但是当我添加它时,它也永远不会触发。

Edit2编辑2

The event seems to work when connecting to a Windows Server 2012 R2.连接到 Windows Server 2012 R2 时,该事件似乎有效。 But not for Server 2016 / 2019.但不适用于 Server 2016 / 2019。


What I tried so far到目前为止我尝试了什么

  • Testing with several implemantations of the class (from MsRdpClient6NotSafeForScripting to MsRdpClient9NotSafeForScripting)使用 class 的几个实现进行测试(从 MsRdpClient6NotSafeForScripting 到 MsRdpClient9NotSafeForScripting)
  • Testing with several settings使用多种设置进行测试

Questions问题

  • Is there any setting which could cause this event not to fire?是否有任何设置可能导致此事件不触发?
  • Is there any alternative to recognize a logon fail?有没有其他方法可以识别登录失败?

Check your ComReference in project file and try setting the WrapperTool to aximp instead of tlbimp.检查项目文件中的 ComReference 并尝试将 WrapperTool 设置为 aximp 而不是 tlbimp。 See if AxInterop is generated after the build and test the remote desktop connection again.查看构建后是否生成了 AxInterop 并再次测试远程桌面连接。

It should be looking something like this它应该看起来像这样

<COMReference Include="RDPCOMAPILib.dll">
    <Guid>cc802d05-ae07-4c15-b496-db9d22aa0a84</Guid>
    <VersionMajor>1</VersionMajor>
    <VersionMinor>0</VersionMinor>
    <WrapperTool>aximp</WrapperTool>
    <Lcid>0</Lcid>
    <Isolated>false</Isolated>
</COMReference>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM