RamblingRoss
The blog of Ross Fruen, a .NET consultant

Connecting to OpenLDAP on Lucid Lynx from S.DS.P

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;

connection.Bind();
...

Add a comment

If you want your comment to appear on this page please complete the form below. Your name and email address are optional, although the latter will be required if you want a response. Your email address will not appear against your comment and will only be used to correspond with yourself (where appropriate).

Thanks!

Thank you for submitting your comment, it will appear here after moderation is complete.

Sorry

There was a problem sending your comment, please try again.