大体是这样的,目前手头没有SSL的AD,没法帮助你测试public class Demo2 { public LdapContext getConnectionFromFool() throws NamingException { String keystore = "D:/soft02/JDK/jre/lib/security/cacerts"; System.setProperty("javax.net.ssl.trustStore", keystore); Properties env = new Properties(); env.put(Context.INITIAL_CONTEXT_FACTORY,"com.sun.jndi.ldap.LdapCtxFactory"); env.put(Context.PROVIDER_URL, "ldap://192.168.0.1:389"); env.put(Context.SECURITY_AUTHENTICATION, "simple"); env.put(Context.SECURITY_PRINCIPAL,"cn=test@domain.com"); env.put(Context.SECURITY_PRINCIPAL,"cn=administrator,cn=Users,dc=all,dc=com"); env.put(Context.SECURITY_CREDENTIALS, "123123"); env.put(Context.SECURITY_PROTOCOL, "ssl"); env.put("com.sun.jndi.ldap.connect.pool", "true"); env.put("java.naming.referral", "follow"); InitialLdapContext dcx = null; dcx = new InitialLdapContext(env, null); return dcx; } }