Deleting an entry : Context « JNDI LDAP « Java






Deleting an entry

   

import java.util.Hashtable;

import javax.naming.Context;
import javax.naming.directory.DirContext;
import javax.naming.directory.InitialDirContext;

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, o=Java.com";

  public static String MGR_PW = "password";

  public static String MY_SEARCHBASE = "o=Java.com";

  public static String MY_ENTRY = "uid=mewilcox, ou=People, o=airius.com";

  public static void main(String args[]) throws Exception {
    Hashtable<String, String> env = new Hashtable<String, String>();
    env.put(Context.INITIAL_CONTEXT_FACTORY, INITCTX);
    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);
    ctx.destroySubcontext(MY_ENTRY);
  }
}

   
    
    
  








Related examples in the same category

1.how to list the name and class of objects in a context
2.how to create a new subcontext called "ou=NewOu" with some attributes
3.how 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