Creating an Initial Context to a Directory : Directory « JNDI LDAP « Java

Creating an Initial Context to a Directory

import java.util.Hashtable;

import javax.naming.Context;

public class Main {
  public static void main(String[] argv) throws Exception {

    String url = "ldap://localhost/o=JNDITutorial";
    Hashtable env = new Hashtable();
    env.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory");
    env.put(Context.PROVIDER_URL, url);

    DirContext ctx = new InitialDirContext(env);


Related examples in the same category

1.Reading an Object's Attributes from the Directory
2.Modifying an Object's Attributes in the Directory
3.Creating a Directory Entry
4.Adding a Binding with Attributes to the Directory
5.Performing a Basic Directory Search
6.Searching the Directory by Using a Search Filter
7.Searching a Subtree in the Directory
8.Cancelling a Directory Search
9.Getting an Object's Schema from the Directory
10.Getting an Attribute's Schema from the Directory
11.Authenticating to the Directory
12.Registering for Namespace Changes in the Directory
13.Registering for Object Changes in the Directory