java - 如何为 ldap DirContext.search(...) 指定搜索范围和返回属性

标签 java ldap

我有一个案例,我必须使用 DirContext 搜索 API 来返回 ldap 搜索的属性。原因是我想要获取的属性是操作属性,如果我没有在搜索命令中专门设置属性名称,它不会返回。

谁能告诉我如何指定搜索范围并同时返回属性?

我没有看到任何 API 允许我这样做。它们要么允许我指定SearchControls,要么指定attributesToReturn,但不能同时指定两者。

search(Name name, Attributes matchingAttributes)
search(Name name, Attributes matchingAttributes,  String[] attributesToReturn)
search(Name name, String filterExpr, Object[] filterArgs, SearchControls cons)
search(Name name, String filter, SearchControls cons)
search(String name, Attributes matchingAttributes)
search(String name, Attributes matchingAttributes, String[] attributesToReturn)
search(String name, String filterExpr, Object[] filterArgs, SearchControls cons)
search(String name, String filter, SearchControls cons)

最佳答案

当然,你不能。您需要使用采用“SearchControls”参数的其他重载之一。

编辑:

Can anyone tell me how to specify the search scope and also returning attribute(s) at the same time?

要返回的属性是 SearchControls 的属性。

关于java - 如何为 ldap DirContext.search(...) 指定搜索范围和返回属性,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19529716/

相关文章:

java - 在 Apache POI 中过滤

java - 使用反射动态调用方法

java - 如何停止 SwingWorker?

java - 如何在带有 Mate Framework 的 Flex 中使用强类型远程服务对象?

php - 为新的 LDAP 用户设置密码

java - Mallet LDA 主题建模中的空主题

active-directory - LDAP 和 Active Directory 结果缺少某些结果的字段

unit-testing - 为内存中的 UnboundID LDAP 服务器创建自定义架构/添加到现有架构

shell - 如何在非交互模式下配置 pam-auth-update?

active-directory - ldaps_search 超出了 LDAP 服务器大小限制 ( MSAD )