gpt4 book ai didi

java - 使用 LDAP 登录 OpenJDK

转载 作者:太空宇宙 更新时间:2023-11-04 09:52:00 24 4
gpt4 key购买 nike

我在使用 LDAP 登录时遇到问题;我使用 OpenJDK 11.0.2、tomcat V7,我使用 MacOS High Sierra(版本 10.13.6)按照代码:

Hashtable<String, Object> env = new Hashtable<String, Object>();
env.put(Context.SECURITY_AUTHENTICATION, "simple");

if(email != null) {
env.put(Context.SECURITY_PRINCIPAL, ldapUsername);
}
if(pwd != null) {
env.put(Context.SECURITY_CREDENTIALS, ldapPassword);
}
env.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory");
env.put(Context.PROVIDER_URL, ldapServer);

log.info("Connecting...");
ctx = new InitialLdapContext(env, null);

当我到达这里时,我收到以下错误:

javax.naming.CommunicationException: simple bind failed: PROVIDER_URL_ SERVER [Root exception is java.net.SocketException: Connection or outbound has closed]

如果我使用 Oracle JDK,代码就可以工作。我把JAVA_HOME从ORACLE JDK改成了OpenJDK,还需要做其他操作吗?

最佳答案

确保 LDAPS 的 SSL 证书已安装在 OpenJDK 的 keystore 中,您可能在 Oracle JDK 的 keystore 中拥有该证书,但在 OpenJDK 中没有。

关于java - 使用 LDAP 登录 OpenJDK,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54615028/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com