Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
301 views
in Technique[技术] by (71.8m points)

asp.net mvc - .NET PricipalContext.ValidateCredentials always returns FALSE

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

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...