1

I have a case that I have to use DirContext search API to return attributes for ldap search. 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. They either allow me to specify SearchControls, or to specify the attributesToReturn, but not both at the same time.

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)
4

1 回答 1

0

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

编辑:

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

返回的属性是SearchControls.

于 2013-10-22T22:48:47.273 回答