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 working 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
. Anyone knows why LdapException comes? Am I missing something in configuration?
question from:
https://stackoverflow.com/questions/65898932/net-pricipalcontext-validatecredentials-always-returns-false 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…