views:

104

answers:

1

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,

A: 

I had the a similar problem with a program to control other machine process's.

I had a piece of code that stalls until login method succeded:

do
{
}
while(!login(usrname, pass));

it does not explain whatever studd is happening but it solved my issue...

Luiscencio
Nick Gotch
it is indeed a better way... less painful...
Luiscencio