I am working on a C# implementation of RDP / MSTSC using the MsRdpClient9NotSafeForScripting class.
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.
From the Microsoft documentation of
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. The once hint I found is: 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?
But from the documentation of the event it should be supported
Minimum supported client Windows Vista
Minimum supported server Windows Server 2008
I downloaded mRemoteNG, which seems to be a very clean implementation of RDP. The event is not used there. But when I add it, it also never fires.
The event seems to work when connecting to a Windows Server 2012 R2. But not for Server 2016 / 2019.
What I tried so far
- Testing with several implemantations of the class (from MsRdpClient6NotSafeForScripting to MsRdpClient9NotSafeForScripting)
- Testing with several settings
- Is there any setting which could cause this event not to fire?
- Is there any alternative to recognize a logon fail?