Sorting Search Results (Windows Embedded CE 6.0)
1/6/2010
When an LDAP client needs sorted results and is not able or is unwilling to perform the sort itself, the client can request that the server do it. The Sort control allows the client to give the server the information required to sort the result set.
The client sends the server a search request with the Sort control, which specifies the sort keys. Each sort key consists of an AttributeType, an Ordering Rule, and a flag that indicates whether entries are sorted in forward or reverse order. The server then tells the client whether the sorting operation is successful and returns entries.
Sort is indicated as a control on the ldap_search_ext function call. To construct this control, the API provides ldap_create_sort_control. The control must then be added to the list of server controls in the ldap_search_ext call. When the server returns the results, it returns a control in the SearchResultDone message to reflect the success or failure of the search. The API provides ldap_parse_search_control as a method of parsing the Sort control as returned by the server in the SearchResultDone message.