Creating and Destroying a Subcontext in the Naming Service : Context « JNDI LDAP « Java

Creating and Destroying a Subcontext in the Naming Service


import java.util.Hashtable;

import javax.naming.Context;
import javax.naming.InitialContext;

public class Main {
  public static void main(String[] argv) throws Exception {
    String url = "iiop://localhost/";
    Hashtable<String, String> env = new Hashtable<String, String>();
    env.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.cosnaming.CNCtxFactory");
    env.put(Context.PROVIDER_URL, url);

    Context ctx = new InitialContext(env);

    // Create a subcontext.
    Context childCtx = ctx.createSubcontext("child");

    // Destroy the subcontext.


Related examples in the same category to list the name and class of objects in a context to create a new subcontext called "ou=NewOu" with some attributes to destroy a subcontext called "ou=NewOu"
4.Listing a Context in the Naming Service
5.Deleting an entry
6.rebind Context
7.tearDown Context Recursively
8.Create a context path recursively.
9.A JNDI context wrapper implementation that delegates read-only methods to its delegate Context, and throws OperationNotSupportedException for any method with a side-effect
10.A static utility class for common JNDI operations
11.JNDI utilities