Results 1 to 3 of 3

Thread: Using LDAP resource with LdapTemplate

  1. #1
    Join Date
    Nov 2007
    Posts
    11

    Default Using LDAP resource with LdapTemplate

    Hi,

    I have my ldap directory context specified as a resource in Tomcat's context.xml:

    Code:
    <Resource name="ldap/myres"
                  auth="Container"
                  type="com.sun.jndi.ldap.LdapCtx"
                  factory="com.mytutorial.LdapContextFactory"
                  java.naming.factory.initial="com.sun.jndi.ldap.LdapCtxFactory"
                  com.sun.jndi.ldap.connect.pool="true"
                  java.naming.provider.url="ldap://localhost:389/dc=mycomp,dc=com"
                  java.naming.security.authentication="simple"
                  java.naming.security.principal="cn=Manager,dc=mycomp,dc=com"
                  java.naming.security.credentials="secret"/>
    Now i would like to use this resource with LdapTemplate instead of specifying LdapContextSource bean. Is this possible? How can I use context resource with LdapTemlate?

    Thanks for answer.

  2. #2
    Join Date
    Mar 2005
    Location
    Landskrona, Sweden
    Posts
    505

    Default

    You will have to create a custom ContextSource implementation. Just implement the ContextSource interface and have your implementation return the resource from JNDI in getReadOnlyContext() and getReadWriteContext(). You might even have it injected to your ContextSource using a JndiFactoryBean to spare you from that trouble.

    Note however that the context will be closed after each LdapTemplate operation. I don't know exactly how this particular managed resource works, but in order for it to work together with Spring LDAP it will have to supply a clean, new LdapContext for each request.
    Mattias Arthursson
    Jayway AB (www.jayway.se)
    Spring-LDAP project member

  3. #3
    Join Date
    Nov 2006
    Location
    germany/sw
    Posts
    14

    Default

    Please add news to this thread also if something new happens here:

    http://forum.springframework.org/showthread.php?t=46222

Posting Permissions

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