0
 var path = abcdev.xyz.com:636;
 PrincipalContext context = new PrincipalContext(ContextType.Domain, path)

 Error:Object reference not set to an instance of an object.

   at System.DirectoryServices.AccountManagement.PrincipalContext.ReadServerConfig(String serverName, ServerProperties& properties)
   at System.DirectoryServices.AccountManagement.PrincipalContext.DoServerVerifyAndPropRetrieval()
   at System.DirectoryServices.AccountManagement.PrincipalContext..ctor(ContextType contextType, String name, String container, ContextOptions options, String userName, String password)
   at System.DirectoryServices.AccountManagement.PrincipalContext..ctor(ContextType contextType, String name)
   at Authenticate(String userName, String password) in c:~\LdapRepository.cs:line 43
   at xyz.Web.LdapController.Login(LdapViewModel model) in C:~\Controllers\LdapController.vb:line 29

The PrincipalContext is working fine for all the clients except one ..I am able to connect to the path = abcdev.xyz.com:636 using Softerra LDAP but not sure why its throwing null object reference ...I have tried abcdev.xyz.com:636/dc=xyz,dc=com -- error server cannot be connected

The url given by client -- ldaps://abcdev.xyz.com:636 The client has verified tht our IP is white Listed So not sure what different should I try for this one client.

Scorpio
  • 1,131
  • 1
  • 17
  • 36
  • Have you tried passing a user name and password in the constructor like new PrincipalContext(ContextType.Domain,path,user,password); I am taking this suggestion from http://stackoverflow.com/questions/14480258/the-ldap-server-is-unavailable – Bearcat9425 Feb 10 '16 at 19:56
  • @Bearcat9425 yes tried tht even tht didnt work – Scorpio Feb 10 '16 at 20:05
  • 2
    This is NOT a duplicate of "what is a NullReferenceException" and that does not answer the question at all. I've hit this myself and the null reference is not in the calling code. This appears to be a bug within System.DirectoryServices.AccountManagement.PrincipalContext.ReadServerConfig, in particular if you reference a non-AD LDAP server with Domain context (likely invalid context, but it's still not a NullReferenceException on the part of the caller). – tjmoore Apr 08 '19 at 13:39
  • Also see https://github.com/dotnet/corefx/issues/31809 – tjmoore Apr 08 '19 at 13:45

0 Answers0