anchor.diff:  
   Once you have an LDAP Server to point your configuration to, you need configure Spring Security to point to an LDAP server that should be used to authenticate users.
   This is done by creating an LDAP `ContextSource`, which is the equivalent of a JDBC `DataSource`.
  +If you have already configured an `EmbeddedLdapServerContextSourceFactoryBean`, Spring Security will create an LDAP `ContextSource` that points to the embedded LDAP server.
  +
  +.LDAP Context Source with Embedded LDAP Server
  +====
  +.Java
  +[source,java,role="primary"]
  +----
  +@Bean
  +public EmbeddedLdapServerContextSourceFactoryBean contextSourceFactoryBean() {
  +	EmbeddedLdapServerContextSourceFactoryBean contextSourceFactoryBean =
  +			EmbeddedLdapServerContextSourceFactoryBean.fromEmbeddedLdapServer();
  +	contextSourceFactoryBean.setPort(0);
  +	return contextSourceFactoryBean;
  +}
  +----
  +
  +.Kotlin
  +[source,kotlin,role="secondary"]
  +----
  +@Bean
  +fun contextSourceFactoryBean(): EmbeddedLdapServerContextSourceFactoryBean {
  +    val contextSourceFactoryBean = EmbeddedLdapServerContextSourceFactoryBean.fromEmbeddedLdapServer()
  +    contextSourceFactoryBean.setPort(0)
  +    return contextSourceFactoryBean
  +}
  +----
  +====
  +
  +Alternatively, you can explicitly configure the LDAP `ContextSource` to connect to the supplied LDAP server.
   
   .LDAP Context Source
   ====
  
positive.code: [source,java,role="primary",attrs="-attributes"]
  ----
  @Bean
  BindAuthenticator authenticator(BaseLdapPathContextSource contextSource) {
  	BindAuthenticator authenticator = new BindAuthenticator(contextSource);
  	authenticator.setUserDnPatterns(new String[] { "uid={0},ou=people" });
  	return authenticator;
  }
  
  @Bean
  LdapAuthenticationProvider authenticationProvider(LdapAuthenticator authenticator) {
  	return new LdapAuthenticationProvider(authenticator);
  }
  ----
  
  
negative.code: ----
  ====
  
  You can then configure the Embedded LDAP Server using an `EmbeddedLdapServerContextSourceFactoryBean`.
  This will instruct Spring Security to start an in-memory LDAP server.
  
  .Embedded LDAP Server Configuration
  ====
  .Java
  [source,java,role="primary"]
  ----
  @Bean
  public EmbeddedLdapServerContextSourceFactoryBean contextSourceFactoryBean() {
  	return EmbeddedLdapServerContextSourceFactoryBean.fromEmbeddedLdapServer();
  }
  ----
  
  .Kotlin
  [source,kotlin,role="secondary"]
  ----
  @Bean
  fun contextSourceFactoryBean(): EmbeddedLdapServerContextSourceFactoryBean {
      return EmbeddedLdapServerContextSourceFactoryBean.fromEmbeddedLdapServer()
  }
  ----
  ====
  
  Alternatively, you can manually configure the Embedded LDAP Server.
  If you choose this approach, you will be responsible for managing the lifecycle of the Embedded LDAP Server.
  
  .Explicit Embedded LDAP Server Configuration
  ====
  .Java
  [source,java,role="primary"]
  