try { CompositeName composite = new CompositeName( "cn=John,o=hits/report/summary.txt"); String first = composite.get(0); // cn=John,o=hits String last = composite.get(composite.size()-1); // summary.txt composite.add(0, "wiz.com"); // wiz.com/cn=John,o=hits/report/summary.txt composite.remove(2); // wiz.com/cn=John,o=hits/summary.txt } catch (NamingException e) { }