Configuring an LDAP server reference

The first step is to configure the embedded LDAP server. Spring Boot will automatically configure an embedded LDAP server, but we will need to tweak the configuration a bit. Make the following updates to your application.yml file:

      //src/main/resources/application.yml

spring:
## LDAP
ldap:
embedded:
           ldif: classpath:/ldif/calendar.ldif
base-dn: dc=jbcpcalendar,dc=com
port: 33389

You should be starting with the source from chapter06.00-calendar.

We are loading the calendar.ldif file from classpath, and using it to populate the LDAP server. The root attribute declares the root of the LDAP directory using the specified DN. This should correspond to the logical root DN in the LDIF file we're using.

Be aware that for embedded LDAP servers, the base-dn attribute is required. If it is not specified or is specified incorrectly, you may receive several odd errors upon initialization of the Apache DS server. Also, be aware that the ldif resource should only load a single ldif, otherwise the server will fail to start up. Spring Security requires a single resource, since using something such as classpath*:calendar.ldif does not provide the deterministic ordering that is required.

We'll reuse the bean ID defined here later, in the Spring Security configuration files, when we declare the LDAP user service and other configuration elements. All other attributes on the <ldap-server> declaration are optional when using the embedded LDAP mode.