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