2 Replies Latest reply on Sep 19, 2012 12:28 PM by EJP

    How to get name of an entry?

      I search in my schema with code below:

      List<OrganizationPojo> organizationPojoList = new ArrayList<OrganizationPojo>();
           DirContext ctx = null;
           try { 
           // get a handle to an Initial DirContext
           ctx = new InitialDirContext(env);
           String[] attrIDs = { "dc", "objectClass","ou" };

           SearchControls ctls = new SearchControls();
           String filter = "(&(dc=*) (objectClass=organizationalUnit) (ou=*))";
           NamingEnumeration answer = ctx.search(searchBaseDn, filter, ctls);
                     while (answer.hasMore())
                               SearchResult sr = (SearchResult) answer.next();
                               LdapName dn = new LdapName((String)sr.getNameInNamespace());
                               LdapName rdn = new LdapName((String)sr.getName());

      I learned SearchResult.getName returns the name "relative to search base"

      But i only want to get the name of entry.

      I am getting dn correctly but can not find out how to get rdn relative to parent in the tree.