I added a WithControls extension method that allows you to specify as many additional DirectoryControls as necessary.
List<User> list = context.Query<User>() .WithControls(new DirectoryControl[] { new PageResultRequestControl(100) { IsCritical = true }, new SortRequestControl(new[]{new SortKey("cn", null, true)}) { IsCritical = true }, new ShowDeletedControl { IsCritical = true } }) .ToList();
If you try to perform an OrderBy or ToPage operation while specifying your own via WithControls then an InvalidOperationException will be thrown.
One cool thing here is behind the scenes I still check if you're requesting a page so you can cast the resulting list as a LdapPage and get the cookie for the next page. And that's about it.
I noticed that you specified multiple directory controls in your search request, specifically PageResultRequestControl and SortRequestControl. When i try to do the same the search completes successfully for the first page of results. However moving to the next page causes an error: "the server does not support the control".
ReplyDeleteIf i don't add the SortRequestControl and just do paging then everything works fine, and vice versa.
Is there a trick to getting a paged search working with both these controls added to the search request?
This seems to be a bug. If you use the filter produced from the LdapPage for a subsequent request, you'll get this error because the QueryTranslator is appending the object class twice. That is invalidating the page request since it's technically a different filter. Try using IgnoreOC in the second request and let me know if that works. I will create a task for this and should have a fix soon. Thanks for catching this!
ReplyDeleteGreat work really , please i have the same problem of "dfranzmann" , is this bug fixed
ReplyDeleteI tried also your workaround but not working
thanks
i found a solution to this problem , you must use the same DirectoryContext and don't create new one in the second request
ReplyDelete