LDAP – Paging Using ldapsearch

ldap

I am searching an LDAP directory that has a much larger number of results than the sizelimit currently set,500, by slapd.conf that for all intents and purposes cannot be changed)

My idea was to keep running ldapsearch but from a different offset each time (501, 1001, etc.) until all results have been obtained.

I have seen the man pages for ldapsearch, and it appears that this is handled for you using the -E options:

-E [!]<ext>[=<extparam>] search extensions (! indicates criticality)
         [!]domainScope              (domain scope)
         [!]mv=<filter>              (matched values filter)
         [!]pr=<size>[/prompt|noprompt]   (paged results/prompt)
         [!]subentries[=true|false]  (subentries)
         [!]sync=ro[/<cookie>]            (LDAP Sync refreshOnly)
                 rp[/<cookie>][/<slimit>] (LDAP Sync refreshAndPersist)

So i tried:
ldapsearch -h $HOST -p $PORT -x -L -b "$BASE" '*' '+' -E pr=$SIZE

However when the results (even paged results with size = 50 for example) hit 500, I get the same error as if the results were not paged:

Size limit exceeded (4)

I have seen in the man pages there is another option for virtuallistview but have been unable to find examples for it, and as well I dont think my version of ldapsearch has this option.

The goal here is to create a backup using ldapsearch and the -L option to create an ldif file that is suitable for restoring the database.

A few google searches show up with the same problem I'm having, but none have an applicable solution..

Best Answer

The directory server administrator is free to impose a limit on the number of entries that can be returned in the response to a search request. The LDAP client can request a size limit, but this client-requested limit cannot override the server-imposed limit. The paging is working correctly: paging simply sends multiple search responses, each the size requested by the client, but still cannot exceed the size limit imposed by the server. The Virtual list View is similar to the simple paging, except that the LDAP client can start and resume anywhere, whereas in simple paged results, the LDAP client must read through results sequentially.