PrincipalContext.ValidateCredentials always returns FALSE

active-directory, activedirectorymembership, asp.net-mvc, c#

Solution

I don't see where you initializes the "pwd" variable Maybe you should use ContextOption in this method to specify exactly the reqired behaviour. Sorry for too broad response but there is no much details in your question

Problem

I have an MVC application that needs to login and verify a user against Active Directory. I am using the `PrincipalContext.ValidateCredentials` method but always get a authentication of `false`. Connecting to the Server is fine. The problem seems to occur in the `ValidateCredentials`. Here is my code: ``` public static bool IsAuthenticated(string domain, string username, string pwd) { bool IsAuthenticated = false; try { PrincipalContext insPrincipalContext = new PrincipalContext(ContextType.Domain, domain, "DC=c1w,DC=com"); username = "c1w\\" + username; IsAuthenticated = insPrincipalContext.ValidateCredentials(username, pwd); } catch (Exception ex) { // Rethrow this exception ExceptionPolicy.HandleException(ex, "Exception Policy"); } return IsAuthenticated; } ``` Anyone know why this would be happening?

Original source