Spring 安全版本 3.1 - 需要使用未添加域的 userPrincipalName 或 sAMAccountName(搜索过滤器?)来匹配用户

Spring security Version 3.1 - Need to match user using either userPrincipalName without domain added OR sAMAccountName (search filter ?)

全部,

我们的 IT 部门已决定更改我们用户在 AD 中的后缀,将不同的后缀添加到 AD 中的 userPrincipalName 到正在使用的实际域中。

例如我们的域名是 xxx.com 但 userPrincipalName 现在是 "usera@zzz.tech" 而之前是 "usera@xxx.com".

Spring LDAP AD 身份验证不再适用于此,我认为是因为这个原因: userPrincipalName 是在尝试进行身份验证时使用名称 + 域构建的。

我需要以某种方式覆盖它 - 但请保持 Spring 安全版本 3.1(理想情况下!)

这是我们使用的安全bean

<bean id="ldapActiveDirectoryAuthProvider" class="org.springframework.security.ldap.authentication.ad.ActiveDirectoryLdapAuthenticationProvider">
    <constructor-arg value="$websec{authentication.base}" />
    <constructor-arg value="$websec{ldap.providerUrl}" />
    <property name="authoritiesMapper" ref="dataAutomationGrantedAuthoritiesMapper" />
    <property name="useAuthenticationRequestCredentials" value="true" />
</bean>

如何覆盖此行为?

谢谢

我们最终修改了 class 的原始 Spring 代码:ActiveDirectoryLdapAuthenticationProvider 并更改方法 createBindPrincipal 以允许与安全根具有不同域的 userPrincipalName 要授权的域。

/**
 * Create bind principal by appending configured user domain to username if it doesn't already contain a domain.
 *
 * @param username  User name for which to create bind principal.
 *
 * @return username, if configured domain is null or the username already contains a domain; otherwise username
 *         appended with the configured user domain.
 */
String createBindPrincipal(final String username) {
    if (domain == null || username.contains("@")) {
        return username;
    }
    return username + "@" + userDomain;
}