Results 1 to 4 of 4

Thread: How to configure LDAP for data access?

  1. #1
    Join Date
    Jul 2010
    Posts
    9

    Default How to configure LDAP for data access?

    Hi I want to declare a LDAP resource in tc Server's context.xml, and refer to it in my Spring App.

    I just want to query LDAP for data access, NOT for authentication.

    This is what I have in Tomcat's context.xml

    <Resource name="ldap/hubdirect"
    auth="Container"
    type="org.springframework.ldap.core.support.LdapCo ntextSource"
    factory="org.springframework.ldap.pool.factory.Dir ContextPoolableObjectFactory"
    java.naming.factory.initial="com.sun.jndi.ldap.Lda pCtxFactory"
    com.sun.jndi.ldap.connect.pool="true"
    java.naming.provider.url="....."
    java.naming.security.authentication="simple"
    java.naming.security.principal="....."
    java.naming.security.credentials="....."/>


    This is what I have in Spring config.xml

    <jee:jndi-lookup id="contextSource" jndi-name="ldap/hubdirect">

    But this is not working at all, and I do not see error message, either.

  2. #2

    Default

    I want to declare a LDAP resource in tc Server's context.xml
    I am not sure why you want to declare your Spring LDAP context source in your server's configuration file. I would just declare the context source in the spring configuration file. Here is an example:

    Code:
       <bean id="contextSource" class="org.springframework.ldap.core.support.LdapContextSource">
          <property name="url" value="ldap://localhost:389" />
          <property name="base" value="dc=example,dc=com" />
          <property name="userDn" ref="example user dn" />
    	<property name="password" ref="example password" />
       </bean>
    You might also want to create a Spring LDAP template that uses this context source:

    Code:
      <bean id="ldapTemplate" class="org.springframework.ldap.core.LdapTemplate">
                <constructor-arg ref="contextSource" />
        </bean>
    Now you can just inject the LDAP template into your spring bean and use it to read LDAP entries.

  3. #3
    Join Date
    Jul 2010
    Posts
    9

    Default

    I'd like to avoid building these values in Spring configuration because they become part of WAR file that is hard to change.

    Having these in Tomcat is lot easier to configure/change as we promote application to different environments.

  4. #4
    Join Date
    Jul 2008
    Posts
    12

    Default

    Hi
    Did you mange to get this working as I can't find a working example......
    Cheers

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •