gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-12-04 04:05:52 24 4
gpt4 key购买 nike

我正在使用 MsRdpClient9NotSafeForScripting class 进行 RDP/MSTSC 的 C# 实现。 .
我需要识别用户登录失败 由于错误的凭据。
事件OnLogonError应该做的工作,但它不触发 (至少不是在 Server 2016 上),而其他事件似乎工作正常。
来自 OnLogonError 的 Microsoft 文档:

LOGON_FAILED_BAD_PASSWORD (0 (0x0))

The logon failed because the logon credentials are not valid.


多次报告该行为(未触发 OnLogonError),但没有解决方案。我发现的一次提示是: at codeproject :

After further testing, I found out that if connecting to a Windows 2003 server, the event is entered. But not when connecting to Win7 and newer and Win2008R2 and newer. I wonder if Microsoft removed the event functionality in newer systems?


但是从事件的文档来看,它应该得到支持

Minimum supported client Windows Vista

Minimum supported server Windows Server 2008



编辑
我下载了 mRemoteNG ,这似乎是一个非常干净的 RDP 实现。那里不使用该事件。但是当我添加它时,它也永远不会触发。
编辑2
连接到 Windows Server 2012 R2 时,该事件似乎有效。但不适用于 Server 2016/2019。

到目前为止我尝试过的
  • 使用类的几个实现进行测试(从 MsRdpClient6NotSafeForScripting 到 MsRdpClient9NotSafeForScripting)
  • 使用多种设置进行测试

  • 问题
  • 是否有任何设置可能导致此事件不触发?
  • 有没有其他方法可以识别登录失败?
  • 最佳答案

    检查项目文件中的 ComReference 并尝试将 WrapperTool 设置为 aximp 而不是 tlbimp。查看构建后是否生成了 AxInterop 并再次测试远程桌面连接。
    它应该看起来像这样

    <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>

    关于c# - 如何识别 RDP/MSTSC 登录失败的时间?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62530215/

    24 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com