Unable to enable SecureSocketLayer with DirectoryServices.Protocols.LdapConnection

I am trying to fix a bug with SSL in the product and noticed that although the code sets SSL as true, the next line of SSL code is still false. I wrote unit test for this, and unit test confirms my suspicions.

[TestMethod] public void SecureSocketLayerSetToTrue( ) { var ldapConnection = new LdapConnection( new LdapDirectoryIdentifier( "ldap.test.com", 636 )); ldapConnection.SessionOptions.SecureSocketLayer = true; Assert.IsTrue( ldapConnection.SessionOptions.SecureSocketLayer ); } 

The test fails. Is there something here that I'm missing?

+4
source share
1 answer

It turns out that the path managed by DirectoryServices.Protocols makes LDAP calls, passing them to the low-level LDAP API. This LDAP API is what is requested when get gets a property.

The low-level API is updated only when methods are executed. You can think about this since it creates command line arguments for an executable file that is not already running.

When a call of type Bind () is executed, the executable is launched and the properties report the correct value.

So, just because the property said the value was false, did it use true when necessary.

+6
source

All Articles