Blog Posts per Tag

LDAP Authentication using Java

import javax.naming.*; import javax.naming.directory.*; import java.util.Hashtable; /** * Demonstrates how to create an initial context to an LDAP server * using simple authentication. */ class Simple { public static void main(String[] args) { Hashtable authEnv = new Hashtable(11); String userName = "johnlennon"; String passWord = "sushi974"; String base = "ou=People,dc=example,dc=com"; String dn = "uid=" + userName + "," + base; String ldapURL = "ldap://ldap.example.com:389"; authEnv.put(Context.INITIAL_CONTEXT_FACTORY,"com.sun.jndi.ldap.LdapCtxFactory"); authEnv.put(Context.PROVIDER_URL, ldapURL); authEnv.put(Context.SECURITY_AUTHENTICATION, "simple"); authEnv.put(Context.SECURITY_PRINCIPAL, dn); authEnv.

Read More →

Meta