Results 1 to 7 of 7

Thread: Using LdapTemplate with JNDI

  1. #1
    Join Date
    Dec 2005
    Posts
    929

    Default Using LdapTemplate with JNDI

    Hi,
    is it possible to configure the LdapContextSource of the LdapTemplate for a JNDI lookup? That is, I have the following specified in my context:

    Code:
    <bean id="ldapTemplate" class="org.springframework.ldap.LdapTemplate">
    	<constructor-arg>
    		<bean class="org.springframework.ldap.support.LdapContextSource">
    		<property name="url" value="${ldap.url}" />
    		<property name="base" value="${ldap.base}" />
    		<property name="userName" value="${ldap.username}" />
    		<property name="password" value="${ldap.password}" />
    		<property name="baseEnvironmentProperties">
    			<map>
    				<entry key="java.naming.referral" value="follow" />
    			</map>
    		</property>
    	</bean>
    	</constructor-arg>
    </bean>
    The $ properties are stored in a properties file. I want to be able to just specify the JNDI name and let WebSphere manage the underlying connection parameters above, like jdbc data sources. Can the template be wrapped in a JndiObjectFactoryBean?
    Thanks
    Alan

  2. #2
    Join Date
    Jul 2005
    Location
    Helsingborg, Sweden
    Posts
    504

    Default

    I would not store the LdapTemplate instance in JNDI, but rather the ContextSource instance, just as you would do with a DataSource. Then it would be trivial to tell ldapTemplate to use a ContextSource which is retrieved from a JndiObjectFactoryBean.
    Ulrik Sandberg
    Jayway (www.jayway.com)
    Spring LDAP project member

  3. #3
    Join Date
    Dec 2005
    Posts
    929

    Default

    Quote Originally Posted by ulsa View Post
    I would not store the LdapTemplate instance in JNDI, but rather the ContextSource instance, just as you would do with a DataSource. Then it would be trivial to tell ldapTemplate to use a ContextSource which is retrieved from a JndiObjectFactoryBean.
    Thanks - I did mean the ContextSource as you say. Configuring a data source for jdbc access is easy in WebSphere 6 but I am not sure how to set up an LDAP connection as a JNDI instance. Anyway, I will try this today.
    Thanks again
    Alan

  4. #4
    Join Date
    Feb 2011
    Posts
    3

    Default

    Did you end up finding a solution to this? We also have jdbc data sources setup in WebSphere (6.1), and access them in the spring context via jndi lookups. However, I cannot seem to figure out how to do the same sort of thing with an LDAP ContextSource.

    Thank you.

  5. #5

    Default

    thanks for this information, it is too important.

  6. #6
    Join Date
    Jun 2012
    Posts
    4

    Default

    Hi, can anyone post the solution if you have? Can we create the Jndi for Ldap ContextSource?
    I do find some posts talking about it, but no solution finally.

  7. #7
    Join Date
    Jul 2008
    Posts
    12

    Default

    I too am looking for this but can't find an example. There are examples that get ldap conn details from jndi but not the ContextSource......

Posting Permissions

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