Is there a way to get only the first N search results using LDAP?

Is there a good way to get only the first N results with an LDAP query to save server load and increase response time?

A use case is, for example, AJAX-based progressive name pickers (via an LDAP-HTTP gateway that wants to limit the size of the request in the LDAP repository directory), which will find all the results, starting with the letters the user has typed so far.

Sample code using the .NET 4.5 System.DirectoryServices.Protocols will be evaluated, but this is not necessary, because if I know what the actual protocol requirements are, I can figure out how to send the request.

+4
source share
3 answers

That for Java PagedResultsControl . There is one in . NET These things implement the protocol for you and simply provide an API.

+3
source

Good answer AJP. Note that although the LDAP client can easily limit itself to only the first N results, order records returned from the search are not repeated. That is, the order of the records returned as a result of the search is not only undefined, it is not guaranteed to be repeated even at the same milliseconds of the connection later. Order-sensitive LDAP clients may experience malfunctions or unexplained results.

+2
source

For your specific purpose (autocomplete suggestion) I would go with ldap sizelimit instead of paged results. Here is the difference:

Size limit

You are interested in the first xx objects. You do not care about everything else, and you do not need the rest.

Results

You are interested in ALL objects, but you want to get them in batches / pages of xx objects on one page. Ultimately, you may need to get all the objects from the server.

The obvious overhead here is that with paginated results, the server should remember the state of your search and resume it accordingly when you request the next page. Since this is usually not necessary for autocomplete lists (if you do not want to be able to expand the autocomplete list further on demand), you can save additional load on your servers by using sizelimit than using the calculated results.

I'm not a .NET programmer, but Google has found this, this may interest you:
system.directoryservices.directorysearcher.sizelimit

For more information, you can also see the RFC pages (do a sizelimit search):
rfc1777

0
source

All Articles