How do I sort LDAP search results?

How do I sort LDAP search results?

Date Entered: 09/26/2007    Last Updated: 09/26/2007

Some LDAP servers support sorting, in which case you can just specify the attributes you'd like to sort by in the SortCriteria property prior to calling the Search method of the component. For example, to get search results sorted by the cn attribute:
//bind first, if necessary:
ldap.DN = "DOMAIN\\User";
ldap.Password = "mypassword";
ldap.Bind();

ldap.DN = "cn=Users,dc=JUNGLE";
ldap.SortAttributes = "cn";
ldap.Search("objectClass=*");

We appreciate your feedback.  If you have any questions, comments, or suggestions about this entry please contact our support team at kb@nsoftware.com.