Skip Navigation Links
Home
+
About
+
Products
+
Support
+
Purchase
+
Search
+
SortBy (Method of LDAPEntryCollection)
Sort the collection by the values of named attributes.
Syntax
SortBy(AttributeName As String, [ SortDirection As axldapSortDirection = axldapSortDirectionAscending ])
Remarks
The SortBy method can be called multiple times on the same collection. Each subsequent call to SortBy has lower priority than previous calls. Subsequent calls add new attribute names to use when sorting the collection. These attribute names are used when the previously-added attributes do not fully order all of the items. If, for example, you are sorting a collection of users, then by sorting on last name, then on first name, all of the Smiths will be returned together, in ascending order of their first name. In addition, the direction of sorting can be specified for each attribute name.
Example
Set pLDAP = CreateObject("LDAPClient.3")
Call pLDAP.Connect("ldapserver")

Set pEntries = pLDAP.Search("o=airius.com", "objectClass=Person")

Call pEntries.SortBy("sn")
Call pEntries.SortBy("givenName")

For Each pEntry In pEntries
    MsgBox pEntry.Attributes("sn").Values(0) + ", " + pEntry.Attributes("givenName").Values(0)
Next