Monday, March 7, 2011

System.DirectoryServices A referral was returned from the server Exception

System.DirectoryServices showed " A referral was returned from the server " Exception just today, and it left me wondering what's wrong?
I was trying to pull data from a Microsoft Active Directory Group, and while attempting to query the data the aforementioned exception was occurring. An eagle eye debugging showed the cause and it was simple but stupid.

Following is the correct format of LDAP connection string


But our dear programmer had done it a little differently, I think it was just a type, the wrong format of LDAP connection string was following


This was causing the system to show the Active Directory related exception in C# .Net on Visual Studio 2008.

Notice the wrong positioning of LDAP port number, people some times make absolutely silly mistakes.

Keep in mind that 389 is default port for insecure communication with LDAP directory server. For secure exchange of data use LDAPS, default port for LDAPS is 636.

These port numbers are recommended, and LDAP servers use these out of the box. But not all LDAP servers always use port 389 and 636. It is possible to change the default LDAP port numbers, please check your directory server software's documentation for details.

I'm working as a freelance programmer through, I have a strong profile over there. Feel free to ping me if you need an Android app.

1 comment:

Feel free to talk back...