Search code examples
javaweblogicjndildap-queryldapconnection

Creating foreign JNDI settings in weblogic and lookup from Java client


Please post if there is any example/steps to configuring external LDAP and execute LDAP queries on it.

I tried the following

  • creating Foreign JNDI Providers
  • Created remote and local JNDI names
  • from servlet client, I tried lookup using foreign jndi name, local and remote jndi names

Finally lookup with local name succeeded, unfortunately that tried to connect localhost:389. Not sure what went wrong.

Please help with any example.


Solution

    1. Create a Foreign JNDI Provider.
    2. Initial context factory: com.sun.jndi.ldap.LdapCtxFactory (i was using openDS LDAP)
    3. Provider URL : "ldap://localhost:389"
    4. User as: cn=Directory Manager
    5. Password: give LDAP password.
    6. Properties:

      com.sun.jndi.ldap.connect.pool=true
      com.sun.jndi.ldap.connect.pool.maxsize=16
      com.sun.jndi.ldap.connect.pool.prefsize=10
      com.sun.jndi.ldap.connect.pool.timeout=600000
      java.naming.referral=follow
      java.naming.security.authentication=simple
      
    7. Create a Foreign JNDI link

      linkname : testLink
      localJndi : testLocalJNDI
      Remote JNDI :  dc=test,dc=org (LDAP BASE DN)
      

    Now you can access the LDAP from your code using the "testLocalJNDI".

    Cheers, Karai