Getting an Object's Fully Qualified Name : Name « JNDI LDAP « Java






Getting an Object's Fully Qualified Name

  
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.
    ctx.destroySubcontext("child");

    Context obj = (Context) childCtx.lookup("grandChild");
    String fullname = obj.getNameInNamespace();
  }
}

   
    
  








Related examples in the same category

1.Using a URL as a Name to the Initial Context
2.Parsing a JNDI Composite Name
3.Parsing a JNDI Compound Name
4.Show only the common name (cn) and e-mail address (mail) attributes
5.Replace the placeholders in the filter with the proper values from the userName