I got two domain user accounts. One has a lower-case user name and another one has mixed-case user name, like "JohnSmith". ValidateCredentials works fine for the lower-case user name. However, for the mixed-case user name it always returns false.
PrincipalContext myDomain = new PrincipalContext(ContextType.Domain, "MyDomain");
bool loginSucceded = myDomain.ValidateCredentials(userName, password);
I can use the following code to see the properties of both accounts (both are enabled). The property LastBadPasswordAttempt suggests that ValidateCredentials returns false not because of wrong password.
PrincipalContext myDomain = new PrincipalContext(ContextType.Domain, "MyDomain");
UserPrincipal user = UserPrincipal.FindByIdentity(myDomain, IdentityType.SamAccountName, userName);
if (user != null)
{
Console.WriteLine("Name: " + user.Name);
Console.WriteLine("DisplayName: " + user.DisplayName);
Console.WriteLine("BadLogonCount: " + user.BadLogonCount);
Console.WriteLine("Enabled: " + user.Enabled);
Console.WriteLine("LastLogon: " + user.LastLogon);
Console.WriteLine("LastBadPasswordAttempt: " + user.LastBadPasswordAttempt);
}
Passing the mixed-case user name converted to lower case did not help either.
UPD: responting to kyndigs' comment, it's a part of investigating an issue in an application that uses ValidateCredentials. Several users reported that they can't login and those users have mixed-case user names.