I am using Spring Security 3.1RC2 and I am using the org.springframework.security.ldap.authentication.ad.ActiveDirectoryLdapAuthenticationProvider object:
<security:authentication-manager>
<security:authentication-provider ref="adAuthenticationProvider" />
</security:authentication-manager>
<bean id="adAuthenticationProvider"
class="org.springframework.security.ldap.authentication.ad.ActiveDirectoryLdapAuthenticationProvider">
<constructor-arg value="DOMAIN" />
<constructor-arg value="ldap://1.1.1.1/" />
</bean>
I can get the security context with SecurityContextHolder.getContext (), which will lead me to the username for the user, but I am trying to figure out how I can go further and get the common name.
As a result of the authentication you will get UserDetails Object in the returned Authentication object. This is done by implementing UserDetailsContextMapper strategy used to map user details with LDAP context data. Check http://static.springsource.org/spring-security/site/docs/3.0.x/reference/ldap.html for more.