Spring seems to have some predefined ldap properties that are available in the application.properties file, such as
spring.ldap.urls=
spring.ldap.base=
spring.ldap.username
spring.ldap.password=
However, it seems that you still have to create a security configuration, where you have to define those properties in code, as Spring complains that it can´t find any AuthenticationProvider
@Configuration
public class SecurityConfig extends WebSecurityConfigurerAdapter {
@Override
protected void configure(AuthenticationManagerBuilder auth) throws Exception {
auth.ldapAuthentication()
.userSearchBase("ou=people")
.userSearchFilter("(uid={0})")
.groupSearchBase("ou=groups")
.groupSearchFilter("(member={0})")
.contextSource().root("dc=baeldung,dc=com")
.ldif("classpath:users.ldif");
}
}
Source https://www.baeldung.com/spring-security-ldap
How can you use those properties without creating an extra configuration where you have to define them again?