-1

I am using this below code to connect to the ldap and assigning roles to the users.

    IdentityStoreFactoryBuilder builder =
            new IdentityStoreFactoryBuilder();
        IdentityStoreFactory oidFactory = null;
        IdentityStore oidStore = null;
        Hashtable factEnv = new Hashtable();
        Hashtable storeEnv = new Hashtable();
        factEnv.put(OIDIdentityStoreFactory.ST_SECURITY_PRINCIPAL, "Obu");
        factEnv.put(OIDIdentityStoreFactory.ST_SECURITY_CREDENTIALS,
                    "password123");
        factEnv.put(OIDIdentityStoreFactory.ST_LDAP_URL,
                    "ldap://localhost:3060/");// here i'm getting exception
        oidFactory =
                builder.getIdentityStoreFactory("oracle.security.idm.providers.oid.OIDIdentityStoreFactory",
                                                factEnv);
        storeEnv.put(OIDIdentityStoreFactory.ADF_IM_SUBSCRIBER_NAME,
                     "dc=us,dc=oracle,dc=com");
        oidStore = oidFactory.getIdentityStoreInstance(storeEnv);

Exception stack trace is:

Exception in thread "main" oracle.security.idm.ConfigurationException: javax.naming.CommunicationException: localhost:3060 [Root exception is java.net.ConnectException: Connection refused: connect]
        at oracle.security.idm.providers.stdldap.TestConnectionPool.execute(LDIdentityStoreFactory.java:1026)
        at oracle.security.idm.providers.stdldap.LDIdentityStoreFactory.setupConnPool(LDIdentityStoreFactory.java:620)
        at oracle.security.idm.providers.stdldap.LDIdentityStoreFactory.setup(LDIdentityStoreFactory.java:333)
        at oracle.security.idm.providers.oid.OIDIdentityStoreFactory.<init>(OIDIdentityStoreFactory.java:56)
        at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
        at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
        at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
        at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
        at oracle.security.idm.IdentityStoreFactoryBuilder.getIdentityStoreFactory(IdentityStoreFactoryBuilder.java:128)
        at view.AddRolesToUsers.main(AddRolesToUsers.java:60)
    Caused by: javax.naming.CommunicationException: localhost:3060 [Root exception is java.net.ConnectException: Connection refused: connect]
        at com.sun.jndi.ldap.Connection.<init>(Connection.java:210)
        at com.sun.jndi.ldap.LdapClient.<init>(LdapClient.java:118)
        at com.sun.jndi.ldap.LdapClient.getInstance(LdapClient.java:1580)
        at com.sun.jndi.ldap.LdapCtx.connect(LdapCtx.java:2652)
        at com.sun.jndi.ldap.LdapCtx.<init>(LdapCtx.java:293)
        at com.sun.jndi.ldap.LdapCtxFactory.getUsingURL(LdapCtxFactory.java:175)
        at com.sun.jndi.ldap.LdapCtxFactory.getUsingURLs(LdapCtxFactory.java:193)
        at com.sun.jndi.ldap.LdapCtxFactory.getLdapCtxInstance(LdapCtxFactory.java:136)
        at com.sun.jndi.ldap.LdapCtxFactory.getInitialContext(LdapCtxFactory.java:66)
        at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:667)
        at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:288)
        at javax.naming.InitialContext.init(InitialContext.java:223)
        at javax.naming.ldap.InitialLdapContext.<init>(InitialLdapContext.java:134)
        at oracle.security.idm.providers.stdldap.TestConnectionPool.run(LDIdentityStoreFactory.java:1006)
    Caused by: java.net.ConnectException: Connection refused: connect
        at java.net.PlainSocketImpl.socketConnect(Native Method)
        at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:351)
        at java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:213)
        at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:200)
        at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:366)
        at java.net.Socket.connect(Socket.java:529)
        at java.net.Socket.connect(Socket.java:478)
        at java.net.Socket.<init>(Socket.java:375)
        at java.net.Socket.<init>(Socket.java:189)
        at com.sun.jndi.ldap.Connection.createSocket(Connection.java:352)
        at com.sun.jndi.ldap.Connection.<init>(Connection.java:187)
user207421
  • 305,947
  • 44
  • 307
  • 483
Obulesu Bukkana
  • 995
  • 4
  • 13
  • 25
  • I used this link to configure LDAP: http://www.oracle.com/webfolder/technetwork/tutorials/obe/fmw/opss/configuring_oid/configureoid.htm – Obulesu Bukkana May 21 '14 at 11:02

3 Answers3

0

java.net.ConnectException: Connection refused means The port name you have specified for the LDAP server is incorrect. Also check for other parameters you are passing those are making it unreachable.

Ninad Pingale
  • 6,801
  • 5
  • 32
  • 55
  • I used this link to configure ldap: will u check it and help me in this issue. http://www.oracle.com/webfolder/technetwork/tutorials/obe/fmw/opss/configuring_oid/configureoid.htm – Obulesu Bukkana May 21 '14 at 11:28
0

Nothing listening at the port. Where did you get port 3060 from? The usual LDAP port is 389, or 636 for LDAPS.

user207421
  • 305,947
  • 44
  • 307
  • 483
  • As you mentioned i changed the ports to 389 and 636 but same issue repeating. Here i'm using LDAP identity store in OPSS. – Obulesu Bukkana May 21 '14 at 12:56
  • The default ports for (OID) are 3060. As mentioned, there is apparently nothing listening on those ports. You could try using netstat to determine if something is running on the 3060 ports. – jwilleke May 21 '14 at 13:18
0

I got the same error. coz I did not give some below props in application.properties. please do not forget to give those props.

spring.ldap.embedded.ldif = classpath:test-server.ldif
spring.ldap.embedded.base-dn = dc=springframework,dc=org
spring.ldap.embedded.port = 8389
Kumaresan Perumal
  • 1,926
  • 2
  • 29
  • 35