ValidateCredentials() returns FALSE on First Call but TRUE on Subsequent Calls

Posted by Nick Gotch on Stack Overflow See other posts from Stack Overflow or by Nick Gotch
Published on 2010-03-18T20:42:18Z Indexed on 2010/03/18 20:51 UTC
Read the original article Hit count: 451

I'm using the following code to authenticate users on my web service:

using (PrincipalContext context = new PrincipalContext(ContextType.Domain, domain))
{
    return context.ValidateCredentials(userName, password);
}

The obstacle I'm running into is that the first call to ValidateCredentials() is returning false but subsequent calls return true. I placed a breakpoint at this line and in the Intermediate window I see the same results: first call returns false, second returns true, even though nothing was changed (by me) between calls.

The 'domain' is String.Empty but I've also tried it with the actual domain name and get the same results.

I'm not that versed in network administration so any help would be appreciated,

© Stack Overflow or respective owner

Related posts about c#

Related posts about windows-authentication