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

Reply via email to