If you are using validating credentials of your users against the Active Directory by using ValidateCredentials method of PrincipalContext in .NET 4 by passing through only the username and password. Most probably it would be taking you roughly 30 seconds to validate credentials and/or this function would be throwing an exception instead of returning false value whenever the wrong credentials being passed to this function.
To resolve this issue what I have found is that the function call
pContext.ValidateCredentials(user, password);
Should be consuming the following value for ContextOptions parameter, by default
ContextOptions.Negotiate | ContextOptions.Signing | ContextOptions.Sealing
But to my findings this is not the case and it seems like to me that unless you provide the following parameters explicitly, the function won't work properly
ContextOptions.Negotiate
or
ContextOptions.Negotiate | ContextOptions.Signing | ContextOptions.Sealing
By providing the parameters mentioned above will not only resolve your validation lag issue but it will also resolve the exception issue with wrong credentials.
So, in a nut shell you should be calling ValidateCredentials function as follows:
pContext.ValidateCredentials(user, password, ContextOptions.Negotiate);
or
pContext.ValidateCredentials(user, password, ContextOptions.Negotiate | ContextOptions.Signing | ContextOptions.Sealing);
To resolve this issue what I have found is that the function call
pContext.ValidateCredentials(user, password);
Should be consuming the following value for ContextOptions parameter, by default
ContextOptions.Negotiate | ContextOptions.Signing | ContextOptions.Sealing
But to my findings this is not the case and it seems like to me that unless you provide the following parameters explicitly, the function won't work properly
ContextOptions.Negotiate
or
ContextOptions.Negotiate | ContextOptions.Signing | ContextOptions.Sealing
By providing the parameters mentioned above will not only resolve your validation lag issue but it will also resolve the exception issue with wrong credentials.
So, in a nut shell you should be calling ValidateCredentials function as follows:
pContext.ValidateCredentials(user, password, ContextOptions.Negotiate);
or
pContext.ValidateCredentials(user, password, ContextOptions.Negotiate | ContextOptions.Signing | ContextOptions.Sealing);
No comments:
Post a Comment
Your comments are highly appreciated!