Reputation: 33
How do I query all descendants of a parent entry in LDAP using UnboundID LDAP SDK?
I am looking for something like a Filter which can say filter based on parent DN. Or some way to list all children of a given Entry.
Is either of it possible using UnboundID LDAP SDK? I am unable to find an example or documentation that mentions this kind of an operation.
Upvotes: 3
Views: 1031
Reputation: 11056
Sure the descendants of any container should be obtained by using LDAP Search Scope
And in UnboundID the Class SearchScope is used in the SearchRequest and shown in their example:
// 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
Upvotes: 3