سؤال

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

هل كانت مفيدة؟

المحلول

Apparently, the culprit was the following piece of code, which was the cause for the delay:

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

Even the debug logs confirmed that the delay was happening when an attempt was being made to set the connection timeout.

Apparently, it seems from the following links, that connection time out does not work when Ldap connection is made with ssl.

Link 1

Link 2

Removing this line of code solved the issue.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top