Parsing a JNDI Compound Name - Java JNDI

Java examples for JNDI:Name

Description

Parsing a JNDI Compound Name

Demo Code

import javax.naming.Context;
import javax.naming.Name;
import javax.naming.NameParser;
import javax.naming.NamingException;

public class Main {
  public static void main(String[] args) {
    try {//from   w  w w  .  j a v  a 2s .com
      Context ctx = null;
      NameParser parser = ctx.getNameParser("");
      Name dn = parser.parse("cn=YourName, ou=People, o=JNDITutorial");

      dn.remove(1); 
      dn.add(0, "c=us"); 
      dn.add("cn=fs"); 
    } catch (NamingException e) {
    }
  }
}

Related Tutorials