-
-
Notifications
You must be signed in to change notification settings - Fork 44
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Feature] Implement true paging support with VLV (Virtual List View) Request #413
Comments
Just looked at it again and saw that the example also includes sorting, so that another thing that may be quite useful to have. |
Hey @KarimGeiger! I've just pushed to I've named the method Here's a usage example: use LdapRecord\Models\ActiveDirectory\User;
/** @var \LdapRecord\Query\Slice **/
$slice = User::slice($perPage = 100, $page = 1, $orderBy = 'cn');
var_dump($slice->items()); Also, it turns out applying sorting is mandatory when requesting a virtual list view:
So an Let me know your thoughts and if you have any issues with it! 👍 |
That's awesome, thanks for that super quick implementation! Unfortunately I don't have time to test today, but I will definitely do so on Monday. I do however have one thing I'm noticing while looking at the example right away, regarding the sorting. I understand that it's needed so I'm not sure if there's a better way to do it, but I'm not super fond of the For one, I would currently be restricted to sorting ascending, so we would need yet another parameter to introduce a direction. Additionally, if you would have previously defined sorting using the Maybe a better way to approach this would be to check if a sorting order has previously been defined, and if it has not, it will always just default to |
Ah great catch @KarimGeiger! Thanks for looking through it 👍 I've updated the implementation so an existing order by will not be overridden by the method. I'll wait for your test before I make the release. |
Okay, we now got around to test it. Unfortunately, we immediately got the following error when running the
Luckily, we found the reason for that error. As the error message suggests, this has nothing to do with some extension being unavailable. Turns out, the problem was that the OU we were searching in had more than 10,000 entries, which exceeds the But, as soon as we switched to an OU with less objects, your implementation worked great and without issues 👍 So, to recap: If you want pagination in Active Directory, you need to find that sweet spot of so many objects that it's worth pagination, but not so many that the server gives up in its default configuration. Fortunately it looks like that variable is configurable, so at least there is a way around it. Thanks again for the quick implementation, apart from AD being AD everything worked fine, so I'd call it a success! |
Thanks for your detailed response @KarimGeiger, I really appreciate it! 🙏 I'm glad it's working. That's lame that AD has a LdapRecord/src/Query/Builder.php Line 622 in e9c9363
Ex: $this->addControl(LDAP_CONTROL_VLVREQUEST, $isCritical = false, [ Not sure if this has any effect. Would you perhaps be able to modify the file and see ? It will be in:
|
We already played around with that parameter while debugging the error message and didn't find any difference whether it's set to |
Ok great, thanks for validating that for me @KarimGeiger. I'll close this issue out once I create a new release 👍 |
Hi @stevebauman, we just noticed one more thing when querying for only one result while using pagination. The affected line is: LdapRecord/src/Query/Builder.php Line 599 in e9c9363
The same happens if the last page only contains one result, for example for 41 results with In this case, the library thinks we have reached the end of the record and therefore discards the only result. We have found that adjusting the line to the following helps to avoid this issue: $objects = $page > ceil($total / $perPage) |
Ah great catch thanks @KarimGeiger! 🙏 This has just been resolved. FYI I've adjusted the parameters to follow the Before: User::slice($perPage = 100, $page = 1); After: User::slice($page = 1, $perPage = 100); I'm creating a new release right now, thanks again for your help! 😄 |
v2.11.0 has just been released 🎉 |
Thanks for letting me know of the parameter change. Will check out the latest release shortly. Great work with the library 👍 |
@KarimGeiger has shown an implementation of a true LDAP pagination request with the ability to set an offset to retrieve a slice of a whole search result from the LDAP server.
Resources:
The text was updated successfully, but these errors were encountered: