Announcement Announcement Module
Collapse
No announcement yet.
How to configure LDAP for data access? Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • 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
    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.

    Comment


    • #3
      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.

      Comment


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

        Comment

        Working...
        X