14 Ekim 2011 Cuma

Spring Security 3.0.5.RELEASE & Secure LDAP Integration

Spring security provides us lots of abilities for different types of authentication meschanisms. LDAP is one of them and in the example below i will try to show how to configure Spring for secure LDAP authentication.

Firstly let us look at our application-context.xml and beans that we should create:

   
   
   


We define a DefaultSpringSecurityContextSource bean which is our security context. For secure LDAP we should have a URL like this: ldaps://ldapServerUrl:636/dc=entp,dc=tgc
636 is the default port for LDAPS. User dn is custom and its format can be like: uid=LDAPSUSER,ou=SpecialUsers,dc=entp,dc=tgc.

Then our second bean is LdapAuthenticationProvider which does the real authentication job.

   
      
         
         
            
               uid={0},ou=People,o=[organizationName]
            
         
      
   
   
      
          
          
          
      
   


Be careful about userDnPatterns for determining the [organizationName].
At last, we define the authentication manager and we are ready for LDAPS authentication.

     


Hiç yorum yok:

Yorum Gönder