Announcement Announcement Module
Collapse
No announcement yet.
How to create Ldap JNDI for Spring Security? Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • How to create Ldap JNDI for Spring Security?

    We are using the Jboss 5.1. Use Spring Security and Ldap for authentication.
    Right now we set the ldap contextsource in xml as below and it works fine.
    <security:ldap-server id="ldapServerAuthentication" url="ldap://10.20.20.152:8389/dc=com"/>

    We want to create it as a JNDI in JBoss 5.1.
    Then use this in xml like <jee:jndi-lookup id="ldapServerAuthentication" jndi-name="ldap/ldapAuthentication"/>

    So I create deploy/ldap-service.xml as below, which I searched out from internet.

    <?xml version="1.0" encoding="UTF-8"?>
    <server>
    <mbean code="org.jboss.naming.ExternalContext" name="jboss.jndi:service=ExternalContext,jndiName= ldap/ldapAuthentication">
    <attribute name="JndiName">ldap/ldapAuthentication</attribute>
    <attribute name="Properties">
    java.naming.factory.initial=com.sun.jndi.ldap.Ldap CtxFactory
    java.naming.provider.url=ldap://10.20.20.152:8389/dc=com
    java.naming.security.credentials=modifier
    java.naming.security.principal=uid=modifier,ou=sys tem,dc=com
    </attribute>
    <attribute name="InitialContext">javax.naming.ldap.InitialLda pContext</attribute>
    <attribute name="RemoteAccess">false</attribute>
    </mbean>
    </server>

    Anyway I got the error,
    nested exception is java.lang.IllegalStateException: Cannot convert value of type [$Proxy142 implementing javax.naming.directory.DirContext,javax.naming.lda p.LdapContext,javax.naming.Context] to required type [org.springframework.ldap.core.support.BaseLdapPath ContextSource]: no matching editors or conversion strategy found

    Think that I should use some Spring ldap classes to create the jndi or have to write the classes, but I can't find any document talking about that.
    Please anyone can help me out? Thank you very much.


    Actually the way I did for the jndi is correct, it returns the javax.naming.directory.DirContext.
    However the spring security <ldap-server> expects the org.springframework.ldap.core.support.BaseLdapPath ContextSource (interface of DefaultSpringSecurityContextSource).
    That's why the erorr msg complains type is not matched.

    So I want to ask further question in another way.
    Is there any way to convert javax.naming.directory.DirContext instance to org.springframework.ldap.core.support.BaseLdapPath ContextSource instance?
    It looks I need the connections between jdk ldap implementation with spring ldap implementation.
    That will solve my problem as well.
    Last edited by PeterSaw; Jun 19th, 2012, 01:13 AM.

  • #2
    Hi
    Did you find a solution to this? There are examples that get ldap conn details from jndi but not the ContextSource......

    Comment


    • #3
      I tried this Code

      I tried this code but this code is not working.


      Natalia
      www.groffr.com
      http://www.groffr.com/mumbai-property
      http://www.groffr.com/noida-property
      http://www.groffr.com/gurgaon-property
      http://www.groffr.com/bangalore-property

      Comment

      Working...
      X