List of usage examples for javax.naming.ldap LdapName remove
public Object remove(int posn) throws InvalidNameException
From source file:Main.java
public static void main(String args[]) { try {/*from w ww. ja va 2 s . c o m*/ LdapName dn = new LdapName("ou=Fruits,o=Food"); LdapName dn2 = new LdapName("ou=Summer"); System.out.println(dn.addAll(dn2)); System.out.println(dn.add(0, "o=Resources")); System.out.println(dn.add("cn=WaterMelon")); System.out.println(dn.remove(1)); System.out.println(dn); } catch (InvalidNameException e) { e.printStackTrace(); } }
From source file:ModifyLdapName.java
public static void main(String args[]) { try {//from w w w . j a va 2s . c o m LdapName dn = new LdapName("ou=Fruits,o=Food"); LdapName dn2 = new LdapName("ou=Summer"); System.out.println(dn.addAll(dn2)); // ou=Summer,ou=Fruits,o=Food System.out.println(dn.add(0, "o=Resources")); // ou=Summer,ou=Fruits,o=Food,o=Resources System.out.println(dn.add("cn=WaterMelon")); // cn=WaterMelon,ou=Summer,ou=Fruits,o=Food,o=Resources System.out.println(dn.remove(1)); // o=Food System.out.println(dn); // cn=WaterMelon,ou=Summer,ou=Fruits,o=Resources } catch (InvalidNameException e) { e.printStackTrace(); } }
From source file:org.lsc.jndi.JndiServices.java
public List<String> sup(String dn, int level) throws NamingException { int ncLevel = (new LdapName(contextDn.toString())).size(); LdapName lName = new LdapName(dn); List<String> cList = new ArrayList<String>(); if (level > 0) { if (lName.size() > level) { for (int i = 0; i < level; i++) { lName.remove(lName.size() - 1); }//from w ww . java2 s.co m cList.add(lName.toString()); } } else if (level == 0) { cList.add(lName.toString()); int size = lName.size(); for (int i = 0; i < size - 1 && i < size - ncLevel; i++) { lName.remove(lName.size() - 1); cList.add(lName.toString()); } } else { return null; } return cList; }
From source file:org.nuxeo.ecm.directory.ldap.LDAPTreeReference.java
protected String getParentDn(String dn) { LdapName ldapName; String parentDn;/*from www.j a v a 2s. c om*/ if (dn != null) { try { ldapName = new LdapName(dn); ldapName.remove(ldapName.size() - 1); parentDn = ldapName.toString(); return parentDn; } catch (InvalidNameException ex) { return null; } } return null; }