Deleting an entry : Context « JNDI LDAP « Java

Deleting an entry


import java.util.Hashtable;

import javax.naming.Context;

public class Main {
  public static String INITCTX = "com.sun.jndi.ldap.LdapCtxFactory";

  public static String MY_HOST = "ldap://localhost:389";

  public static String MGR_DN = "uid=yourid, ou=People,";

  public static String MGR_PW = "password";

  public static String MY_SEARCHBASE = "";

  public static String MY_ENTRY = "uid=mewilcox, ou=People,";

  public static void main(String args[]) throws Exception {
    Hashtable<String, String> env = new Hashtable<String, String>();
    env.put(Context.PROVIDER_URL, MY_HOST);
    env.put(Context.SECURITY_AUTHENTICATION, "simple");
    env.put(Context.SECURITY_PRINCIPAL, MGR_DN);
    env.put(Context.SECURITY_CREDENTIALS, MGR_PW);
    DirContext ctx = new InitialDirContext(env);


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.Creating and Destroying a Subcontext in the Naming Service
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