Reputation: 957
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?
Upvotes: 0
Views: 183