更改针对 AD 搜索时@domain结尾



Domain

DC=red,DC=xyz

公元userPrincipalName: firstname.lastname@blue.com

@Bean
    public AuthenticationProvider activeDirectoryLdapAuthenticationProvider() {
        ActiveDirectoryLdapAuthenticationProvider ap =
                new ActiveDirectoryLdapAuthenticationProvider(domain, url);
        ap.setSearchFilter("(userPrincipalName={0})"); //change @ ending here?
        ap.setConvertSubErrorCodesToExceptions(true);
        ap.setUseAuthenticationRequestCredentials(true);
        ap.setUserDetailsContextMapper(userDetailsContextMapper);
        return ap;
    }

此代码成功针对 AD 进行身份验证,并尝试使用userPrincipalName: firstname@red.xyz搜索树DC=red,DC=xyz

搜索失败,因为 @red.xyz 已过时且使用了 @blue.com。如何在不更改域的情况下重新配置 java 中的 @ 结尾?

问题是userPrincipalName与AD用户名和域端不同。默认情况下,ActiveDirectoryLdapAuthenticationProvider 添加搜索参数username@domain。

作为解决方案,我覆盖了ActiveDirectoryLdapAuthenticationProvider,并将搜索过滤器更改为sAMAccountName,并将值更改为没有域的纯用户名。

最新更新