savan savani

savan savani

  • NA
  • 8
  • 14k

Error in PrincipalContext.ValidateCredentials

Feb 19 2018 6:15 AM
I have used below code to authenticate user with Active Directory.
  1. using (PrincipalContext principalContext1 = new PrincipalContext(ContextType.Domain, domainName))  
  2. {  
  3. if (principalContext1.ValidateCredentials(userName, password))  
  4. {  
  5. //code to successful login  
  6. }  
  7. }  
Getting error "The server cannot handle directory requests." in ValidateCredentials method.
I have tried passing contextOptions as third parameter "ContextOptions.Negotiate | ContextOptions.Signing | ContextOptions.Sealing" in ValidateCredentials method.
It resolved my error, but I came to know from msdn that it is default parameter.
 
Why should I need to pass this? Any alternative solutions? Thanks in advance.

Answers (2)