【发布时间】:2018-11-20 10:01:23
【问题描述】:
请找到我的以下代码并帮助我连接到 LDAP。
我的代码如下:
Hashtable<String, String> environment = new Hashtable<String, String>();
environment.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory");
environment.put(Context.PROVIDER_URL, "ldap://192.168.0.214:389");
environment.put(Context.SECURITY_AUTHENTICATION, "simple");
environment.put(Context.SECURITY_PRINCIPAL, "CN=Administrator,CN=Users,DC=estsecondary,DC=com");
environment.put(Context.SECURITY_CREDENTIALS, "*****8");
try {
LdapContext ctx = new InitialLdapContext(environment, null);
}catch (AuthenticationNotSupportedException exception) {
System.out.println("The authentication is not supported by the server");
} catch (AuthenticationException exception){
System.out.println("Incorrect password or username");
}catch (NamingException exception){
System.out.println("Error when trying to create the context");
}
但我无法连接。我收到“服务器不支持身份验证”。请在下面找到我的 LDAP 结构。
【问题讨论】:
-
您能否包含您在第 12 行捕获的异常的堆栈跟踪?
-
服务器好像不支持认证类型。存在三种身份验证类型,包括“无”。以下是有关身份验证类型的更多信息:docs.oracle.com/javase/tutorial/jndi/ldap/auth_mechs.html
-
服务器不支持身份验证[LDAP:错误代码 8 - BindSimple:需要传输加密。]
-
可以添加e.printStackTrace(); before System.out.println("服务器不支持认证");并共享错误堆栈?