This discussion is archived
2 Replies Latest reply: Sep 19, 2012 5:28 AM by EJP RSS

How to get name of an entry?

823810 Newbie
Currently Being Moderated
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 =, filter, ctls);
               while (answer.hasMore())
                         SearchResult sr = (SearchResult);
                         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.


  • Correct Answers - 10 points
  • Helpful Answers - 5 points