Spring Security and multiple ldap configuration

Jerome Cance picture Jerome Cance · May 30, 2012 · Viewed 11.7k times · Source

I use Spring Security to manage user and group securities.

All datas are stored in a ldap server. My configuration is the following:

  <authentication-manager alias="authenticationManager">
         <ldap-authentication-provider 
           user-search-filter="(mail={0})"
           user-search-base=""
           group-search-filter="(uniqueMember={0})"
           group-search-base="ou=groups"
           group-role-attribute="cn"
           role-prefix="ROLE_"
           user-context-mapper-ref="contextMapper">
         </ldap-authentication-provider>
         <lda
  </authentication-manager>

  <beans:bean id="contextMapper" class="com.mycompany.CustomContextMapper">
    <beans:property name="indexer" ref="entityIndexer" />
  </beans:bean>

  <ldap-user-service  server-ref="ldapServer" user-search-filter="(mail={0})" />

  <ldap-server manager-dn="cn=admin,dc=springframework,dc=org" manager-password="password" url="ldap://server/dc=springframework,dc=org" id="ldapServer" />

All runs like a charm. Now, I want to add a second ldap server if the first one is down (fallback). I can't find an easy way to do it.

So, my question si simple: how to add a second ldap server in this config to provide a fallback if the first one is down ?

Answer

Ritesh picture Ritesh · May 30, 2012

Use space delimited value for url attribute:

url="ldap://server1/dc=springframework,dc=org ldap://server2/dc=springframework,dc=org"

Ref: LDAP & LDAPS URLs