简体   繁体   English

如何使用 LDAP 查询对 LDAP 结果进行排序?

[英]How to sort LDAP Result with LDAP Query?

I'm creating a LDAP directory search using PHP and we're using Novell as our LDAP server.我正在使用 PHP 创建一个 LDAP 目录搜索,我们使用 Novell 作为我们的 LDAP 服务器。 I'm able to successfully search and return results;我能够成功搜索并返回结果; this is the current filter I'm running, (&(FERPA=N)(|(uid=*searchphrase*)(sn=*searchphrase*)(fullName=*searchphrase*)(telephoneNumber=*searchphrase*))) .这是我正在运行的当前过滤器(&(FERPA=N)(|(uid=*searchphrase*)(sn=*searchphrase*)(fullName=*searchphrase*)(telephoneNumber=*searchphrase*)))

I want to be able to sort by last name, or the LDAP variable sn .我希望能够按姓氏或 LDAP 变量sn排序。 I could sort it via PHP, but I want that to be the last resort.我可以通过 PHP 对其进行排序,但我希望这是最后的选择。 Is there a way to sort the results based on a column.有没有办法根据列对结果进行排序。 For example, in SQL you can sort based on a column like this, SELECT * FROM TABLE WHERE COL='criteria' ORDER BY COL;例如,在 SQL 中,您可以根据这样的列进行排序, SELECT * FROM TABLE WHERE COL='criteria' ORDER BY COL; Is there something similar that can be done with LDAP Queries?有没有类似的东西可以用 LDAP 查询来完成?

LDAP client applications that require results of search requests to be ordered in a repeatable way should use the server-side sort extension . LDAP 需要以可重复方式对搜索请求结果进行排序的客户端应用程序应使用服务器端排序扩展 In most cases, use of the server-side sort extension requires the application coder to inform the directory administrators so that proper indexing can be setup.在大多数情况下,使用服务器端排序扩展需要应用程序编码人员通知目录管理员,以便可以设置正确的索引。

As far as I know there is no way to sort results with a LDAP filter.据我所知,无法使用 LDAP 过滤器对结果进行排序。 All a filter does is limit what entries are returned.过滤器所做的只是限制返回的条目。

With php, you would run your search, then sort the result with http://us3.php.net/manual/en/function.ldap-sort.php使用 php,您将运行搜索,然后使用http://us3.php.net/manual/en/function.ldap-sort.php对结果进行排序

Alternatively, you could read all the entries into an array and then run one of php's other sorting functions on them.或者,您可以将所有条目读入一个数组,然后对它们运行 php 的其他排序函数之一。 http://us1.php.net/manual/en/array.sorting.php http://us1.php.net/manual/en/array.sorting.php

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM