3

I would like to know how to configure 2 ldap server in spring xml or java config. I mean I'm not referring to using the @Primary. I have 2 different LDAP servers. User will authenticate to which server depending on which domain they are in. For example, if their domain is domain1, then they need to authenticate to ldap1, otherwise they will authenticate to lda2. I tried configuring two ldap-server but Im getting an error saying onlg 1 is allowed.

iPhoneJavaDev
  • 821
  • 5
  • 33
  • 78

1 Answers1

1

I figured out the answer to my question. I created 2 configuration classes, each with its own LdapContextSource. Then each has the LdapTemplate bean, one without the identifier, the other one has:

Config1:

@Bean
public LdapTemplate ldapTemplate(@Qualifier("ldapServer1") LdapContextSource contextSource) {
    return new LdapTemplate(contextSource);
}

Config2:

@Bean(name = "ldapTemplateDomain2")
public LdapTemplate ldapTemplate(@Qualifier("ldapServer2") LdapContextSource contextSource) {
    return new LdapTemplate(contextSource);
}
iPhoneJavaDev
  • 821
  • 5
  • 33
  • 78