title: Ldap access forbidden spring security
body: <p>My SecurityConfig:</p>
  <pre><code>@Configuration
  @EnableGlobalMethodSecurity(securedEnabled = true, jsr250Enabled = true)
  @EnableWebSecurity
  public class SecurityConfiguration extends WebSecurityConfigurerAdapter
  {
     @Override
     protected void configure(HttpSecurity httpSecurity) throws Exception
     {
        // @formatter:off
        httpSecurity
                 .antMatcher(&quot;/**&quot;).authorizeRequests()
                 .antMatchers(&quot;/boards/**&quot;).permitAll()
                 .anyRequest().authenticated()
                 .and().csrf().csrfTokenRepository(CookieCsrfTokenRepository.withHttpOnlyFalse())
                 .and().exceptionHandling()
                 .accessDeniedPage(&quot;/accessDenied&quot;);
        // @formatter:on
     }
     @Override
     public void configure(AuthenticationManagerBuilder auth) throws Exception
     {
        auth.ldapAuthentication()
            .userDnPatterns(&quot;uid={0},ou=people&quot;)
            .userSearchBase(&quot;ou=people&quot;)
            .userSearchFilter(&quot;uid={0}&quot;)
            .groupSearchBase(&quot;ou=groups&quot;)
            .groupSearchFilter(&quot;uniqueMember={0}&quot;)
            .contextSource()
            .url(&quot;ldap://localhost:8389/dc=concretepage,dc=com&quot;)
            .and()
            .passwordCompare()
            .passwordEncoder(passwordEncoder())
            .passwordAttribute(&quot;userPassword&quot;);
     }
  
     @Bean
     public PasswordEncoder passwordEncoder() {
        return new BCryptPasswordEncoder();
     }
  </code></pre>
  <p>My <code>ldap.ldif</code></p>
  <pre><code>dn: dc=concretepage,dc=com
  objectclass: top
  objectclass: domain
  objectclass: extensibleObject
  dc: concretepage
  
  dn: ou=groups,dc=concretepage,dc=com
  objectclass: top
  objectclass: organizationalUnit
  ou: groups
  
  dn: ou=people,dc=concretepage,dc=com
  objectclass: top
  objectclass: organizationalUnit
  ou: people
  
  dn: uid=krishna,ou=people,dc=concretepage,dc=com
  objectclass: top
  objectclass: person
  objectclass: organizationalPerson
  objectclass: inetOrgPerson
  cn: Krishna Sharma
  sn: Sharma
  uid: krishna
  userPassword: $2a$10$S8V5m0T40n9hhzLtRZpUYuSF38b88axEKIDyVrXtA8b8LN0CB6CRq
  
  
  dn: uid=surya,ou=people,dc=concretepage,dc=com
  objectclass: top
  objectclass: person
  objectclass: organizationalPerson
  objectclass: inetOrgPerson
  cn: Surya Singh
  sn: Singh
  uid: surya
  userPassword: $2a$10$FXjepdY6oNJuUGGFEuyPFOJ/i7BjFcW1hfq8WClVjXbVq7suNu2A2
  
  dn: cn=developers,ou=groups,dc=concretepage,dc=com
  objectclass: top
  objectclass: groupOfUniqueNames
  cn: developers
  ou: developer
  uniqueMember: uid=krishna,ou=people,dc=concretepage,dc=com
  uniqueMember: uid=surya,ou=people,dc=concretepage,dc=com
  
  dn: cn=managers,ou=groups,dc=concretepage,dc=com
  objectclass: top
  objectclass: groupOfUniqueNames
  cn: managers
  ou: manager
  uniqueMember: uid=krishna,ou=people,dc=concretepage,dc=com
  </code></pre>
  <p>I try to access the <code>/labels/xxxx</code> with postdam by passing username and password but i get an accessDenied:
  <a href="https://i.stack.imgur.com/zopk8.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/zopk8.png" alt="enter image description here" /></a></p>
  <p>Second variant with <code>BasicAuth</code>
  <a href="https://i.stack.imgur.com/EcgmB.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/EcgmB.png" alt="enter image description here" /></a></p>
  <p>The <code>/board/xyqas</code> is available</p>