複数のLDAP/ドメインサーバーがあります。(例:)可用性を確認して、そのうちの1つを使用する必要がありますLDAP://server1.com:389/DC=server1,DC=COM
。LDAP://server2.com:389/DC=server2,DC=COM
try {
Hashtable<String, String> env = new Hashtable<String, String>();
env.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory");
env.put(Context.PROVIDER_URL, "LDAP://server1.com:389/DC=server1,DC=COM");
env.put(Context.SECURITY_AUTHENTICATION, "simple");
env.put(Context.SECURITY_PRINCIPAL, username);
env.put(Context.SECURITY_CREDENTIALS, password);
DirContext ctx = new InitialDirContext(env);
} catch(NamingException ex) {
}