java.naming.communication exception :( mydomain name):636(port)[根异常是java.net.connectException:连接时间到时:连接]
这是我以下的Java代码,我尝试通过在Active Directory和Java中设置SSL来验证管理员。
public class Unicode_passwordLdap{
public static void main(String[] args){
LdapContext ctx = null;
try{
Security.addProvider(new com.sun.net.ssl.internal.ssl.Provider());
System.setProperty("javax.net.ssl.trustStore", "C://Java//jre1.8.0_331//lib//security//cacerts");
System.setProperty("javax.net.ssl.trustStorePassword", "changeit");
System.setProperty("javax.net.ssl.keyStore", "C://Java//jre1.8.0_331//lib//security//cacerts");
System.setProperty("javax.net.ssl.keyStorePassword","changeit");
System.setProperty("javax.net.debug", "all");
String baseName = ",CN=Users,DC=trial,DC=com";
Hashtable env = new Hashtable();
env.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory");
env.put(Context.SECURITY_AUTHENTICATION, "Simple");
env.put(Context.SECURITY_PRINCIPAL, "cn=administrator" + baseName); //"[email protected]"
env.put(Context.SECURITY_CREDENTIALS, "admin1*"); //"Panda123*"
env.put(Context.PROVIDER_URL, "ldaps://WS2K19.trail.com:636"); //dc=trial,dc=com
//ldaps://WS2K19.trail.com:636
env.put(Context.SECURITY_PROTOCOL, "ssl");
ctx = new InitialLdapContext(env,null);
System.out.println("Connection Successfull");
}catch(Exception e){
//System.out.println("Password Cannot be Changed");
e.printStackTrace();
}
}
}
这是我遇到的以下错误,当我运行此Java代码时:
javax.naming.CommunicationException: WS2K19.trail.com:636 [Root exception is java.net.ConnectException: Connection timed out: connect]
at com.sun.jndi.ldap.Connection.<init>(Connection.java:235)
at com.sun.jndi.ldap.LdapClient.<init>(LdapClient.java:137)
at com.sun.jndi.ldap.LdapClient.getInstance(LdapClient.java:1615)
at com.sun.jndi.ldap.LdapCtx.connect(LdapCtx.java:2847)
at com.sun.jndi.ldap.LdapCtx.<init>(LdapCtx.java:348)
at com.sun.jndi.ldap.LdapCtxFactory.getLdapCtxFromUrl(LdapCtxFactory.java:225)
at com.sun.jndi.ldap.LdapCtxFactory.getUsingURL(LdapCtxFactory.java:189)
at com.sun.jndi.ldap.LdapCtxFactory.getUsingURLs(LdapCtxFactory.java:243)
at com.sun.jndi.ldap.LdapCtxFactory.getLdapCtxInstance(LdapCtxFactory.java:154)
at com.sun.jndi.ldap.LdapCtxFactory.getInitialContext(LdapCtxFactory.java:84)
at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:694)
at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:313)
at javax.naming.InitialContext.init(InitialContext.java:244)
at javax.naming.ldap.InitialLdapContext.<init>(InitialLdapContext.java:154)
at Unicode_passwordLdap.main(Unicode_passwordLdap.java:63)
有人可以帮助解决此错误!!!
This is my following java code, where I try to authenticate administrator by setting up ssl in active directory and java.
public class Unicode_passwordLdap{
public static void main(String[] args){
LdapContext ctx = null;
try{
Security.addProvider(new com.sun.net.ssl.internal.ssl.Provider());
System.setProperty("javax.net.ssl.trustStore", "C://Java//jre1.8.0_331//lib//security//cacerts");
System.setProperty("javax.net.ssl.trustStorePassword", "changeit");
System.setProperty("javax.net.ssl.keyStore", "C://Java//jre1.8.0_331//lib//security//cacerts");
System.setProperty("javax.net.ssl.keyStorePassword","changeit");
System.setProperty("javax.net.debug", "all");
String baseName = ",CN=Users,DC=trial,DC=com";
Hashtable env = new Hashtable();
env.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory");
env.put(Context.SECURITY_AUTHENTICATION, "Simple");
env.put(Context.SECURITY_PRINCIPAL, "cn=administrator" + baseName); //"[email protected]"
env.put(Context.SECURITY_CREDENTIALS, "admin1*"); //"Panda123*"
env.put(Context.PROVIDER_URL, "ldaps://WS2K19.trail.com:636"); //dc=trial,dc=com
//ldaps://WS2K19.trail.com:636
env.put(Context.SECURITY_PROTOCOL, "ssl");
ctx = new InitialLdapContext(env,null);
System.out.println("Connection Successfull");
}catch(Exception e){
//System.out.println("Password Cannot be Changed");
e.printStackTrace();
}
}
}
This is the following error I get, when I run this java code:
javax.naming.CommunicationException: WS2K19.trail.com:636 [Root exception is java.net.ConnectException: Connection timed out: connect]
at com.sun.jndi.ldap.Connection.<init>(Connection.java:235)
at com.sun.jndi.ldap.LdapClient.<init>(LdapClient.java:137)
at com.sun.jndi.ldap.LdapClient.getInstance(LdapClient.java:1615)
at com.sun.jndi.ldap.LdapCtx.connect(LdapCtx.java:2847)
at com.sun.jndi.ldap.LdapCtx.<init>(LdapCtx.java:348)
at com.sun.jndi.ldap.LdapCtxFactory.getLdapCtxFromUrl(LdapCtxFactory.java:225)
at com.sun.jndi.ldap.LdapCtxFactory.getUsingURL(LdapCtxFactory.java:189)
at com.sun.jndi.ldap.LdapCtxFactory.getUsingURLs(LdapCtxFactory.java:243)
at com.sun.jndi.ldap.LdapCtxFactory.getLdapCtxInstance(LdapCtxFactory.java:154)
at com.sun.jndi.ldap.LdapCtxFactory.getInitialContext(LdapCtxFactory.java:84)
at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:694)
at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:313)
at javax.naming.InitialContext.init(InitialContext.java:244)
at javax.naming.ldap.InitialLdapContext.<init>(InitialLdapContext.java:154)
at Unicode_passwordLdap.main(Unicode_passwordLdap.java:63)
Could someone help to solve this error!!!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论