@Override protected AuthenticationProvider getDelegate() { ActiveDirectoryConfig adConfig = authConfigRepository.findActiveDirectory(true) .orElseThrow(() -> new BadCredentialsException("Active Directory is not configured")); ActiveDirectoryLdapAuthenticationProvider adAuth = new ActiveDirectoryLdapAuthenticationProvider(adConfig.getDomain(), adConfig.getUrl(), adConfig.getBaseDn()); adAuth.setAuthoritiesMapper(new NullAuthoritiesMapper()); adAuth.setUserDetailsContextMapper(new DetailsContextMapper(ldapUserReplicator, adConfig.getSynchronizationAttributes())); return adAuth; }