Clear the sort criteria.
ClearSort
Set pLDAP = CreateObject("LDAPClient.3")
Call pLDAP.Connect("ldapserver")
Set pEntries = pLDAP.Search("o=airius.com", "objectClass=Person")
' Sort by sn, then givenName
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
Call pEntries.ClearSort
' Now sort by givenName first and show results again.
Call pEntries.SortBy("givenName")
Call pEntries.SortBy("sn")
For Each pEntry In pEntries
MsgBox pEntry.Attributes("givenName").Values(0) + " " + pEntry.Attributes("sn").Values(0)
Next