Hello,
I am using spring-security 3.1.0.RC3.
I did setup like that :
So I can have LDAP authentication and database right management :Code:<beans:bean id="contextSource" class="org.springframework.security.ldap.DefaultSpringSecurityContextSource"> <beans:constructor-arg index="0" value="ldap://clusterldap.mycorp.com:389/dc=corp,dc=mycorp,dc=com" /> <beans:property name="userDn" value="cn=readldap,dc=mycorp,dc=com" /> <beans:property name="password" value="lecture" /> </beans:bean> <beans:bean id="ldapUserSearch" class="org.springframework.security.ldap.search.FilterBasedLdapUserSearch"> <beans:constructor-arg index="0" value="ou=people" /> <beans:constructor-arg index="1" value="(uid={0})" /> <beans:constructor-arg index="2" ref="contextSource" /> <beans:property name="searchSubtree" value="true" /> </beans:bean> <beans:bean id="myAuthoritiesPopulator" class="com.mycorp.myproject.web.MyAuthoritiesPopulator" /> <beans:bean id="ldapAuthProvider" class="org.springframework.security.ldap.authentication.LdapAuthenticationProvider"> <beans:constructor-arg index="0"> <beans:bean class="org.springframework.security.ldap.authentication.BindAuthenticator"> <beans:constructor-arg index="0" ref="contextSource" /> <beans:property name="userSearch" ref="ldapUserSearch" /> </beans:bean> </beans:constructor-arg> <beans:constructor-arg index="1" ref="myAuthoritiesPopulator" /> <beans:property name="userDetailsContextMapper" ref="myUserDetailsContextMapper" /> </beans:bean> <authentication-manager alias="authenticationManager"> <authentication-provider ref="ldapAuthProvider" /> </authentication-manager>
I also created a user bean :Code:public class MyAuthoritiesPopulator implements LdapAuthoritiesPopulator { @Autowired private MyCredentialsService myCredentialsService; @Override public Collection<? extends GrantedAuthority> getGrantedAuthorities(DirContextOperations userData, String username) { final List<GrantedAuthority> authorities = newArrayList(); final MyUser user = myCredentialsService.searchUser(username); // token final List<GrantedAuthority> grantedAuthorities = getAuthorities(user.getRoles()); authorities.addAll(grantedAuthorities); return authorities; } private List<GrantedAuthority> getAuthorities(List<RoleEnum> roles) { final List<GrantedAuthority> grantedAuthorities = newArrayList(transform(roles, new Function<RoleEnum, GrantedAuthority>() { public GrantedAuthority apply(RoleEnum role) { return new SimpleGrantedAuthority(role.getCode()); } })); return grantedAuthorities; } }
But I do not understand (from the web and the documentation) how I can auto bind the ldap values into MyLdapUserCode:public class MyLdapUser { String firstname; string lastname; string email ... }
Any help would be helpfull.


Reply With Quote