I am trying to connect to an LDAP server in C# using PrincipalContext. I've validated the network parameters and authentication settings are all correct using Apache Directory Studio. This is the code I'm using:
string sDomain = @"vds.myCompany.net:1234";
string sDefaultOU = @"ou=apdev,ou=ads,o=vds";
string sUser = @"myUsername";
string sPassword = @"myPassword";
ContextOptions options = ContextOptions.SimpleBind | ContextOptions.SecureSocketLayer;
PrincipalContext context = new PrincipalContext(ContextType.Domain, sDomain, null, options, sUser, sPassword);
I must connect using SSL and my credentials are SSO. I've tried with and without specifying the sDefaultOU as the container parameter. The error it throws at the last line is:
System.NullReferenceException: 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)