Enabling the LDAP AuthenticationProviderNext interface

Next, we'll need to configure another AuthenticationProvider interface that checks user credentials against the LDAP provider. Simply update the Spring Security configuration to use an o.s.s.ldap.authentication.LdapAuthenticationProvider reference, as follows:

    //src/main/java/com/packtpub/springsecurity/configuration/SecurityConfig.java

@Override
public void configure(AuthenticationManagerBuilder auth)
throws Exception {
auth
.ldapAuthentication()
.userSearchBase("")
.userSearchFilter("(uid={0})")
.groupSearchBase("ou=Groups")
.groupSearchFilter("(uniqueMember={0})")
.contextSource(contextSource())
.passwordCompare()
.passwordAttribute("userPassword");
}
@Bean
public DefaultSpringSecurityContextSource contextSource() {
return new DefaultSpringSecurityContextSource(
Arrays.asList("ldap://localhost:33389/"),
"dc=jbcpcalendar,dc=com");
}

We'll discuss these attributes a bit more later. For now, get the application back up and running, and try logging in with admin1@example.com as the username and admin1 as the password. You should be logged in!

Your source code should look like chapter05.01-calendar.