directory-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From <Carlo.Acco...@ibs-ag.com>
Subject Fastest way to get Entry when you have the String DN
Date Tue, 29 Jan 2013 10:38:23 GMT
Hi,
We've been getting an entry from a String DN by constructing DN and Rdn objects, creating
a search request, SearchCursor, then loop the response for the single entry.
If I have the DN  uid=123,ou=foo,o=bar   Is there a more exact way in the API to get the Entry
(without searching) if we already have a LdapConnection and valid String DN?


              Dn dn = "uid=123.ou=foo,o=bar";

              SearchRequest req = new SearchRequestImpl();
              req.addAttributes(DEFAULT_ATTRIBUTES);
              req.setScope(SearchScope.ONELEVEL);
              Rdn rdn =dn.getRdn(); // gets uid=123
              Dn dnBase = dn.getAncestorOf(rdn.getName()); // gets ou=foo,o=bar
              req.setFilter("("+rdn.getName()+")");
              req.setBase(dnBase);
              req.setSizeLimit(1);
              SearchCursor cursor = connection.search(req);
              try {
              Entry entry = null;
              while(cursor.next()){
                     Response response = cursor.get();
                     entry = ((SearchResultEntry)response).getEntry();
              }
              SearchResultDone done = cursor.getSearchResultDone();
              ....



Thanks


Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message