Example usage for org.springframework.security.ldap.userdetails LdapUserDetailsMapper setPasswordAttributeName

List of usage examples for org.springframework.security.ldap.userdetails LdapUserDetailsMapper setPasswordAttributeName

Introduction

In this page you can find the example usage for org.springframework.security.ldap.userdetails LdapUserDetailsMapper setPasswordAttributeName.

Prototype

public void setPasswordAttributeName(String passwordAttributeName) 

Source Link

Document

The name of the attribute which contains the user's password.

Usage

From source file:au.edu.anu.orcid.security.SecurityConfig.java

@Autowired
public void configureGlobal(AuthenticationManagerBuilder auth) throws Exception {
    Properties properties = PropertyLoader.loadProperties("ldap.properties");
    LdapUserDetailsMapper contextMapper = new LdapUserDetailsMapper();
    //contextMapper.setRoleAttributes(new String[]{"affiliation"});
    contextMapper.setPasswordAttributeName("password");

    String ldapUri = properties.getProperty("ldap.uri");
    String baseDn = properties.getProperty("ldap.baseDn");

    String contextLdapUri = ldapUri + "/" + baseDn;

    LOGGER.debug("Ldap Url: {}", contextLdapUri);

    auth.ldapAuthentication().userDnPatterns("uid={0}, ou=People").contextSource().url(contextLdapUri).and()
            .userDetailsContextMapper(contextMapper);
}