Announcement Announcement Module
Collapse
No announcement yet.
Using LDAP resource with LdapTemplate Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

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

    Comment


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

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

      Comment

      Working...
      X