I work in C # and try to use DirectorySearch to query groups of the extremely large Microsoft ActiveDirectory LDAP server.
So, in my application I will have a computed list of searchable groups. Naturally, I donโt want to clog my LDAP server, passing me the whole set of results for these queries every time I click โNext Pageโ.
Is there a way, using DirectorySearch, to retrieve ONLY one arbitrary page result, and not return the entire result in a single method call?
Related questions:
There are many such questions when someone asks about swap (from the LDAP server to the application server) and receives answers related to the PageSize and SizeLimit parameters. However, these properties only affect the search call between the C # server and the LDAP server, and ultimately the only relevant methods that DirectorySearch have are FindOne () and FindAll ().
What I'm looking for is basically โFindPaged (pageSize, pageNumber)โ (the page number is a really important bit. I don't need the first 1000 results, I want (for example) the 100th set of 1000. The application cannot wait for 100,000 entries that will be transferred from the LDAP server to the application server, even if they are divided into 1000 entries.
I understand that DirectoryServices.Protocols has SearchRequest, which (I think?) Allows you to use "PageResultRequestControl", which looks like it has what I'm looking for (although it looks like the swap information is being sent to cookies ", which I'm not sure how I should have received.) But if there is a way to do this without rewriting everything in order to use the protocols instead, I would prefer not to.
I just can't imagine there is no way to do this ... Even SQL has a Row_Number.
UPDATE: PageResultRequestControl does not help - it is only for direct and sequential (you must call and get the first N results before you can get the cookie token needed to make the call to get the result N + 1).
However, the cookie has some kind of reproducible order ... In the result set that I worked on, I repeated one by one according to the results, and every time the cookie came out this way:
1: {8, 0, 0, 0} 2: {11, 0, 0, 0} 3: {12, 0, 0, 0} 4: {16, 0, 0, 0}
When I repeated two or two, I got the same numbers (11, 16). This makes me think that if I could define a code for how these numbers are generated, I could create an ad-hoc cookie that would give me exactly the paging I'm looking for.