0

I am using Jboss 4.2.3 and I am trying to connect to LDAP server and calling this piece of code to create the initial context:

Hashtable<String, String> environment = new Hashtable<String, String>();
environment.put(Context.PROVIDER_URL, ldapUrl);
environment.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory");
environment.put(Context.SECURITY_AUTHENTICATION, "simple");
environment.put(Context.SECURITY_PROTOCOL, "ssl");
environment.put(Context.REFERRAL, "follow");
environment.put(Context.SECURITY_PRINCIPAL, principalName);
environment.put(Context.SECURITY_CREDENTIALS, plainPassword);
environment.put("com.sun.jndi.ldap.connect.pool", "true");
environment.put("com.sun.jndi.ldap.connect.timeout", "1500");


context = new InitialLdapContext(environment, null);

The Initial context creation is taking 12 seconds which is not acceptable. However, if I run this same program as a standalone java program in the same system, it executes in 1 second.

How can I analyse the cause for this delay inside the JBoss server ? How do I debug this problem ? Kindly help

4

1 回答 1

0

显然,罪魁祸首是以下代码,这是导致延迟的原因:

environment.put("com.sun.jndi.ldap.connect.timeout", "1500");

甚至调试日志也确认在尝试设置连接超时时发生了延迟。

显然,从以下链接看来,当使用 ssl 建立 Ldap 连接时,连接超时不起作用。

链接 1

链接 2

删除这行代码解决了这个问题。

于 2014-05-07T09:27:04.870 回答