0

I have Domain authentication implemented in the ASP.NET project. Using 4.5 .Net frameworks, 3.0.1 Microsoft.Owin dependencies.

Here is how I am validating the user trying to login:

using (var context = new PrincipalContext(ContextType.Domain, domain, username, password))
{
    ApplicationUser user = UserManager.FindByName(username);
    if (user != null)
    {
        var signInStatus = context.ValidateCredentials(username, password, ContextOptions.SimpleBind);
        // next code based on signInStatus value 
    }
} 

I tried many answers on Stack Overflow but nothing worked for me. Any help will be very much appreciated.

EDIT

I looked into the PrincipalContext.validateCredentials method and found that it returns false when app receives LdapException. Does anyone know why LdapException comes? Am I missing something in configuration?

User16119012
  • 957
  • 11
  • 25
  • What is the `ErrorCode` value in the `LdapException`? – Jackdaw Feb 03 '21 at 16:19
  • @Jackdaw, it is `ERROR_LOGON_FAILURE = 0x31`. – User16119012 Feb 04 '21 at 18:13
  • Your validation process seems correct. Therefore, there is nothing to do but consider all possible reasons. Look at the error description [invalidCredentials (49)](https://ldap.com/ldap-result-code-reference-core-ldapv3-result-codes/#rc-invalidCredentials). And try to check all the listed problems step by step. – Jackdaw Feb 04 '21 at 18:37

0 Answers0