如何使用UnboundID LDAP SDK查询LDAP中父条目的所有后代?
我正在寻找类似过滤器的东西,可以说基于父DN的过滤器。或者某种方式列出给定条目的所有子项。
是否可以使用UnboundID LDAP SDK?我无法找到提及此类操作的示例或文档。
答案 0 :(得分:3)
在UnboundID中,SearchScope中使用了SearchRequest类并在其示例中显示:
// Construct a filter that can be used to find everyone in the Sales
// department, and then create a search request to find all such users
// in the directory.
Filter filter = Filter.createEqualityFilter("ou", "Sales");
SearchRequest searchRequest =
new SearchRequest("dc=example,dc=com", SearchScope.SUB, filter,
"cn", "mail");
SearchResult searchResult;
try
{
searchResult = connection.search(searchRequest);
for (SearchResultEntry entry : searchResult.getSearchEntries())
{
String name = entry.getAttributeValue("cn");
String mail = entry.getAttributeValue("mail");
}
}
catch (LDAPSearchException lse)
{
// The search failed for some reason.
searchResult = lse.getSearchResult();
ResultCode resultCode = lse.getResultCode();
String errorMessageFromServer = lse.getDiagnosticMessage();
}
-Jim