Example usage for javax.naming.ldap LdapName add

List of usage examples for javax.naming.ldap LdapName add

Introduction

In this page you can find the example usage for javax.naming.ldap LdapName add.

Prototype

public Name add(int posn, Rdn comp) 

Source Link

Document

Adds a single RDN at a specified position within this LDAP name.

Usage

From source file:Main.java

public static void main(String args[]) {
    try {//ww w .j  a  v a2 s . c om
        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 ww  .  j a  va2 s. 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();
    }
}