spring-guides / gs-authenticating-ldap

Authenticating a User with LDAP :: Learn how to secure an application with LDAP.
https://spring.io/guides/gs/authenticating-ldap/
Apache License 2.0
98 stars 154 forks source link

Not working #38

Closed rajanpanchal closed 1 year ago

rajanpanchal commented 4 years ago

This gives error

aused by: javax.naming.CommunicationException: localhost:8389
    at com.sun.jndi.ldap.Connection.<init>(Connection.java:238) ~[na:1.8.0_201]
    at com.sun.jndi.ldap.LdapClient.<init>(LdapClient.java:137) ~[na:1.8.0_201]
    at com.sun.jndi.ldap.LdapClientFactory.createPooledConnection(LdapClientFactory.java:64) ~[na:1.8.0_201]
    at com.sun.jndi.ldap.pool.Connections.<init>(Connections.java:114) ~[na:1.8.0_201]
    at com.sun.jndi.ldap.pool.Pool.getPooledConnection(Pool.java:136) ~[na:1.8.0_201]
    at com.sun.jndi.ldap.LdapPoolManager.getLdapClient(LdapPoolManager.java:340) ~[na:1.8.0_201]
    at com.sun.jndi.ldap.LdapClient.getInstance(LdapClient.java:1601) ~[na:1.8.0_201]
    at com.sun.jndi.ldap.LdapCtx.connect(LdapCtx.java:2749) ~[na:1.8.0_201]
    at com.sun.jndi.ldap.LdapCtx.<init>(LdapCtx.java:319) ~[na:1.8.0_201]
    at com.sun.jndi.ldap.LdapCtxFactory.getUsingURL(LdapCtxFactory.java:192) ~[na:1.8.0_201]
    at com.sun.jndi.ldap.LdapCtxFactory.getUsingURLs(LdapCtxFactory.java:210) ~[na:1.8.0_201]
    at com.sun.jndi.ldap.LdapCtxFactory.getLdapCtxInstance(LdapCtxFactory.java:153) ~[na:1.8.0_201]
    at com.sun.jndi.ldap.LdapCtxFactory.getInitialContext(LdapCtxFactory.java:83) ~[na:1.8.0_201]
    at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:684) ~[na:1.8.0_201]
    at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:313) ~[na:1.8.0_201]
    at javax.naming.InitialContext.init(InitialContext.java:244) ~[na:1.8.0_201]
    at javax.naming.ldap.InitialLdapContext.<init>(InitialLdapContext.java:154) ~[na:1.8.0_201]
    at org.springframework.ldap.core.support.LdapContextSource.getDirContextInstance(LdapContextSource.java:42) ~[spring-ldap-core-2.3.3.RELEASE.jar:2.3.3.RELEASE]
    at org.springframework.ldap.core.support.AbstractContextSource.createContext(AbstractContextSource.java:343) ~[spring-ldap-core-2.3.3.RELEASE.jar:2.3.3.RELEASE]
    ... 59 common frames omitted
Caused by: java.net.ConnectException: Connection refused (Connection refused)
dsyer commented 4 years ago

I’m pretty sure it works for me, if you mean the app and tests in the “complete” sample. What is “this”? What did you run, and how? What about the rest of the stacktrace?

rfencl commented 4 years ago

I ran into the same problem but got it working. The unit tests were not working. I added this dependency

org.springframework.security spring-security-test 5.3.4.RELEASE test

and that fixed everything.