From 71a662bd1f796db32b3746ff7cedb77f93a299af Mon Sep 17 00:00:00 2001 From: Doris Lam Date: Tue, 13 Sep 2022 13:52:58 -0700 Subject: [PATCH] support multiple userDnPatterns, use ; as delimiter --- .../java/org/openmbee/mms/ldap/LdapSecurityConfig.java | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/ldap/src/main/java/org/openmbee/mms/ldap/LdapSecurityConfig.java b/ldap/src/main/java/org/openmbee/mms/ldap/LdapSecurityConfig.java index 8f0adc6f4..2f798a260 100644 --- a/ldap/src/main/java/org/openmbee/mms/ldap/LdapSecurityConfig.java +++ b/ldap/src/main/java/org/openmbee/mms/ldap/LdapSecurityConfig.java @@ -48,8 +48,8 @@ public class LdapSecurityConfig { @Value("${ldap.provider.base:#{null}}") private String providerBase; - @Value("${ldap.user.dn.pattern:uid={0}}") - private String userDnPattern; + @Value("#{'${ldap.user.dn.pattern:uid={0}}'.split(';')}") + private List userDnPattern; @Value("${ldap.user.attributes.username:uid}") private String userAttributesUsername; @@ -99,7 +99,8 @@ public void configureLdapAuth(AuthenticationManagerBuilder auth, We redefine our own LdapAuthoritiesPopulator which need ContextSource(). We need to delegate the creation of the contextSource out of the builder-configuration. */ - auth.ldapAuthentication().userDnPatterns(userDnPattern).groupSearchBase(groupSearchBase) + String[] a = userDnPattern.toArray(new String[0]); + auth.ldapAuthentication().userDnPatterns(a).groupSearchBase(groupSearchBase) .groupRoleAttribute(groupRoleAttribute).groupSearchFilter(groupSearchFilter) .rolePrefix("") .ldapAuthoritiesPopulator(ldapAuthoritiesPopulator)