Tomcat + LDAP issue: socket closed on connection

active-directoryldaptomcat

I'm trying to configure Tomcat to connect to an LDAP server on our network, and I'm getting the following error:

javax.naming.ServiceUnavailableException: xx.xx.xx.xx:636; socket closed
at com.sun.jndi.ldap.Connection.readReply(Connection.java:419)
at com.sun.jndi.ldap.LdapClient.ldapBind(LdapClient.java:340)
at com.sun.jndi.ldap.LdapClient.authenticate(LdapClient.java:192)
at com.sun.jndi.ldap.LdapCtx.connect(LdapCtx.java:2694)

Here is the attempted Realm:

    <Realm className="org.apache.catalina.realm.JNDIRealm" debug="99"
        connectionName="CN=username,CN=users,DC=domain-name,DC=com"
        connectionPassword="password"
        connectionURL="ldap://xx.xx.xx.xx:636"
        userPattern="CN={0},CN=users,DC=domain-name,DC=com"
        roleBase="DC=domain-name,DC=com"
        roleName="CN"
        roleSearch="CN={1}"
    />

I'm not sure why this is happening, as using Softerra LDAP Admin. works with the same login information (the same DN and password).

Edit: just figured out that JXplorer doesn't work and fails with the same error, but Softerra does not.

Best Answer

Look much like a software-firewall issue. You need to configure the firewall in question to allow the particular processes (java.exe and so on) to access the port in question. I however wonder if you didn't get a security dialogue beforehand which should have asked you to allow or block the access.