3

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.

1 Answers1

3

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

jwilleke
  • 10,467
  • 1
  • 30
  • 51