2
votes

I have installed OpenLDAP for Windows on my machine, but not able to connect to my local LDAP sever from my ASP.NET application.

The first step I have in my code is the creation a new DirectoryEntry instance:

DirectoryEntry entry = new DirectoryEntry("LDAP://maxcrc.com");

It throws an exception saying "The sever is not operational"

I have tried LDAP clients programs and they seem to connect fine to localhost or (127.0.0.1) with the following DCs:

DC=maxcrc,DC=com

I tried several ways to connect but nothing including (LDAP://localhost, LDAP://DC=maxcrc,DC=com or LDAP://localhost/DC=maxcrc,DC=com)

1

1 Answers

0
votes

If I remember correctly, you need to specify the port number when connecting via DirectoryEntry:

DirectoryEntry entry = new DirectoryEntry("LDAP://localhost:389");

I would, however, recommend taking a look at the System.DirectoryServices.Protocols namespace for actually facilitating the server connection, particularly the LdapConnection class - this question is a good starting point, and does a good job of illustrating the benefits of this approach.

Also, keep in mind that traffic going over port 389 (ldap vs. ldaps) will be in plain-text, which can be insightful when diagnosing connection issues. Wireshark is your best friend in this scenario, and has built in TCP filters specifically for LDAP communications.