C# ValidateCredentials fails on Windows 10 with System.IO.FileNotFoundException: The system cannot find the file specified.

When you try to validate credentials using .NET on Windows 10 you may get the rather confusing errror

System.IO.FileNotFoundException: The system cannot find the file specified.


The full exception trace looks like this

System.IO.FileNotFoundException: The system cannot find the file specified.

   at System.DirectoryServices.AccountManagement.UnsafeNativeMethods.IADs.Get(String bstrName)
   at System.DirectoryServices.AccountManagement.CredentialValidator.BindSam(String target, String userName, String password)
   at System.DirectoryServices.AccountManagement.CredentialValidator.Validate(String userName, String password, ContextOptions connectionMethod)
   at System.DirectoryServices.AccountManagement.PrincipalContext.ValidateCredentials(String userName, String password, ContextOptions options)


To resolve this make sure that the RegisteredOwner and RegisteredOrganization string values are found here HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Microsoft\Windows NT\CurrentVersion.

More information can be found here
https://developer.microsoft.com/en-us/microsoft-edge/platform/issues/6638841/

Alternatively you can make sure that your project is not running in x86 mode.



Comments

  1. Hi,

    A user of our application is getting that error. But when he's using the VPN which will gather access to the domain, he doesn't get it. However, users shouldn't need to connect to the VPN in order to login. Do you think that issue has to do with your explanation above ?

    ReplyDelete

Post a Comment

Popular posts from this blog

Windows Server 2016, 2019, 2022, Windows 10 and Windows 11: Date and time "Some settings are managed by your organization".

TFTPD32 or TFTPD64 reports Bind error 10013 An attempt was made to access a socket in a way forbidden by its access permissions.

Enable function lock for F1-F12 on HP ZBook mobile workstations