Class UseridAttributeLdapContextMapper

  • All Implemented Interfaces:

    public class UseridAttributeLdapContextMapper
    The purpose of this class is to provide a means of normalizing user ids in case-insensitive LDAP environments. This was successfully tested with MS Active Directory, but should also work with any other directory that is case insensitive. The problem being addressed is well stated in BISERVER-5994. This mapper gets used in place of the default LdapUserDetailsMapper in the applicationContext-spring-security-ldap.xml To install this class, you need to do the following:
    1. Modify applicationContext-spring-security-ldap.xml
    2. Locate the bean daoAuthenticationProvider
    3. After the constructor arg bits, add a new property as follows:
    4.     <property name="userDetailsContextMapper">
            <ref local="ldapContextMapper" />
    5. Below the close of the definition of the daoAuthenticationProvider bean, create the ldapContextMapper bean as shown - make sure you update the property name to match your environment. The default is samAccountName
    6.    <bean id="ldapContextMapper" class="">
           <property name="ldapUsernameAttribute" value="samAccountName" />
    • Constructor Detail

      • UseridAttributeLdapContextMapper

        public UseridAttributeLdapContextMapper()
    • Method Detail

      • mapUserFromContext

        public mapUserFromContext​(org.springframework.ldap.core.DirContextOperations ctx,
                                                                                            String username,
                                                                                            Collection<? extends> authorities)
        Specified by:
        mapUserFromContext in interface
        mapUserFromContext in class
      • setLdapUsernameAttribute

        public void setLdapUsernameAttribute​(String value)
        Sets the name of the LDAP attribute to use for the login name after authentication.

        Example - cn

        Default value: samAccountName

        Set the value as a bean property in the applicationContext-spring-security-ldap.xml

        value -
      • getLdapUsernameAttribute

        public String getLdapUsernameAttribute()