Summary
I'm using the LdapAuthenticationProviderConfigurer for my spring security LDAP configuration.
Actual Behavior
Actually, i don't find a way to set the hideUserNotFoundExceptions property in the built LdapAuthenticationProvider (by LdapAuthenticationProviderConfigurer)
Expected Behavior
Allow hideUserNotFoundExceptions property to be set in auth
.ldapAuthentication() without redefining a complet LdapAuthentificationProvider
@Autowired
public void configureGlobal(AuthenticationManagerBuilder auth) throws Exception {
auth
.ldapAuthentication()
}
Configuration
@Autowired
public void configureGlobal(AuthenticationManagerBuilder auth) throws Exception {
auth
.ldapAuthentication()
.userDnPatterns(securityProperties.getLdap().getUserDn())
.groupSearchFilter("(uniqueMember={0})")
.groupSearchBase(securityProperties.getLdap().getGroupDn())
.userDetailsContextMapper((customUserDetailsContextMapper())
.contextSource(contextSource())
.rolePrefix(ROLE_PREFIX)
.passwordCompare()
.passwordAttribute("userPassword");
}
Version
1.5.1.RELEASE
Sample
Comment From: dmitryogorodnikov63
Temporary solution:
@Component
public class LdapAuthenticationProviderBeanPostProcessor implements BeanPostProcessor {
@Override
public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException {
if (bean instanceof LdapAuthenticationProvider) {
((LdapAuthenticationProvider) bean).setHideUserNotFoundExceptions(false);
}
return bean;
}
}