簡體   English   中英

如何為ldap DirContext.search(…)一起指定搜索范圍和返回屬性

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

我有一種情況,我必須使用DirContext搜索API返回ldap搜索的屬性。 原因是我要獲取的屬性是“操作屬性”,如果我沒有在搜索命令中專門設置屬性名稱,它將不會返回。

誰能告訴我如何指定搜索范圍並同時返回屬性?

我看不到有任何API允許我這樣做。 它們要么允許我指定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)

當然不能。 您需要使用帶有“ SearchControls”參數的其他重載之一。

編輯:

誰能告訴我如何指定搜索范圍並同時返回屬性?

要返回的屬性是SearchControls.的屬性SearchControls.

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM