简体   繁体   English

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

[英]how to specify search scope and returning attributes together for ldap DirContext.search(…)

I have a case that I have to use DirContext search API to return attributes for ldap search. 我有一种情况,我必须使用DirContext搜索API返回ldap搜索的属性。 The reason is the attribute I want to get is Operational Attribute, and it wont return if I don't specifically set the attribute name on search command. 原因是我要获取的属性是“操作属性”,如果我没有在搜索命令中专门设置属性名称,它将不会返回。

Can anyone tell me how to specify the search scope and also returning attribute(s) at the same time? 谁能告诉我如何指定搜索范围并同时返回属性?

I don't see there are any APIs allowing me to do that. 我看不到有任何API允许我这样做。 They either allow me to specify SearchControls, or to specify the attributesToReturn, but not both at the same time. 它们要么允许我指定SearchControls,要么指定attributeToReturn,但不能同时指定两者。

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)

You can't, of course. 当然不能。 You need to use one of the other overloads that takes a 'SearchControls' argument. 您需要使用带有“ SearchControls”参数的其他重载之一。

EDIT: 编辑:

Can anyone tell me how to specify the search scope and also returning attribute(s) at the same time? 谁能告诉我如何指定搜索范围并同时返回属性?

The attributes to return are a property of SearchControls. 要返回的属性是SearchControls.的属性SearchControls.

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

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