When attempting to connect to OpenLDAP running on Ubuntu 10.4 (Lucid Lynx) it is necessary to explicitly set the ProtocolVersion of the SessionOptions used by the System.DirectoryServices.Protocols.LdapConnection to 3 otherwise a binding error is generated.

Another little wrinkle involves the use of SSL connections over port 636. It is not enough to just set the port number in the LdapDirectoryIdentifier parameter, it is also necessary to to set the SecureSocketLayer property to true within the SessionOptions.

An example follows...

AuthType authType = AuthType.Basic;

if (!string.IsNullOrEmpty((AuthenticationType)))
    authType = (AuthType)Enum.Parse(typeof(AuthType), AuthenticationType, true);

LdapConnection connection = new LdapConnection(new LdapDirectoryIdentifier(LdapServer), new NetworkCredential(UserName, Password), authType);

connection.SessionOptions.ProtocolVersion = 3;

connection.SessionOptions.SecureSocketLayer = UseSSL;

December 8, 2010

Add a comment