Mar
27
|
To use anonymous access for an LDAP search or query set the value of Context.SECURITY_AUTHENTICATION to “none” in the environment used to create the initial context.
Hashtable env = new Hashtable(); env.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory"); env.put(Context.PROVIDER_URL, providerUrl); // Use 'none' for anonymous access env.put(Context.SECURITY_AUTHENTICATION, "none"); // Create the initial context DirContext ctx = new InitialDirContext(env);
Leave a Reply
You must be logged in to post a comment.