title: How to use Active directory docker image for authorization in spring boot application
body: <p>This is my first time to work with Docker and AD.<br></p>
  
  <p>I am implementing a spring boot application that uses Active directory for authorization.<br></p>
  
  <p>I have gone through LDAP tutorial <a href="https://spring.io/guides/gs/authenticating-ldap/" rel="nofollow noreferrer">https://spring.io/guides/gs/authenticating-ldap/</a></p>
  
  <p>I have downloaded a docker image of Active Directory. </p>
  
  <p><a href="https://hub.docker.com/r/pitkley/samba-ad-dc/#environment-variables" rel="nofollow noreferrer">https://hub.docker.com/r/pitkley/samba-ad-dc/#environment-variables</a></p>
  
  <p>Now i want to use this docker image for authorization in my local machine.</p>
  
  <p>Docker image is running,</p>
  
  <p><code>$ docker run -i -t 041144877f9f /bin/bash
  root@3c01c419c248:/#</code></p>
  
  <p><strong>How i can use this image in my spring boot app for authorization? <br>
  What should i expect from this docker image?</strong></p>
  
  <p>I use mac, java, spring boot.
  Below is my code,</p>
  
  <pre><code>@Configuration
  public class WebSecurityConfig extends WebSecurityConfigurerAdapter {
  
      @Override
      protected void configure(HttpSecurity http) throws Exception {
          http
              .authorizeRequests()
                  .anyRequest()
                  .fullyAuthenticated()
                      .and()
                  .formLogin();
      }
  
      @Override
      public void configure(AuthenticationManagerBuilder auth) throws Exception {
          auth
          .ldapAuthentication()
              .userDnPatterns("uid={0},ou=people")
              .groupSearchBase("ou=groups")
              .contextSource(contextSource())
              .passwordCompare()
                  .passwordEncoder(new LdapShaPasswordEncoder())
                  .passwordAttribute("userPassword");
      }
  
      @Bean
      public DefaultSpringSecurityContextSource contextSource() {
          return  new DefaultSpringSecurityContextSource(Arrays.asList("ldap://localhost:8389/"), "dc=springframework,dc=org");
      }
  }
  </code></pre>