public static String INITCTX = "com.sun.jndi.ldap.LdapCtxFactory"; /* * Host name and port number of LDAP server */ public static String MY_SERVICE = "ldap://10.46.33.2:389";
public static void main(String[] args) {
//需要到sun下载jndi LDAP Service Provider, 1.2.4 包 //http://java.sun.com/products/jndi/downloads/index.html Hashtable env = new Hashtable(); env.put(Context.INITIAL_CONTEXT_FACTORY, INITCTX); env.put(Context.PROVIDER_URL, MY_SERVICE); env.put(Context.SECURITY_AUTHENTICATION, "simple");