none
Validating credential for principal context RRS feed

  • Question

  • I am trying to validate credential for principal context using below code. But it is giving error "the server cannot handle directory requests".

    context.ValidateCredentials("Username", "Password");

    After doing some internet search I came to know that I need to pass another parameter ContextOptions to make it work.

    context.ValidateCredentials("Username", "Password", ContextOptions.Negotiate);

    It is working. But I cannot understand the root cause. If anyone can explain it in detail then it will be very helpful. 

    Thanks.

    Wednesday, July 6, 2016 12:07 PM

All replies

  • Try this



    BP-LP 2005/2016 @ll rights reserved

    Wednesday, July 6, 2016 10:40 PM
  • Hi Belarmino,

    I tried that earlier and it works as well, but I can't understand what is a root cause for this exception.

    Thursday, July 7, 2016 4:31 AM
  • Hi Bhargav,

    As far as I know, if you are using validating credentials of your users against the Active Directory by using the 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.

    So, 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);
    Best Regards,
    Li Wang

    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Thursday, July 7, 2016 8:34 AM
    Moderator
  • Thanks for information Li Wang. But it is not taking time and directly throws the exception.

    Given solution works fine but can you explain the root cause in more detail?

    Thursday, July 7, 2016 2:13 PM
  • Sorry, I can't :( 

    I just search something that would help you


    BP-LP 2005/2016 @ll rights reserved

    Thursday, July 7, 2016 8:45 PM
  • Thanks Belarmino.
    Tuesday, July 12, 2016 12:02 PM
  • :) 

    BP-LP 2005/2016 @ll rights reserved

    Tuesday, July 12, 2016 9:27 PM