0
votes

I am using spring-security-ldap to add LDAP authentication to my application. It is configured like so:

auth.ldapAuthentication()
          .userSearchBase(ldapConfigProperties.getUserSearchBase())
          .userSearchFilter(ldapConfigProperties.getUserSearchFilter())
          .contextSource()
          .managerDn(ldapConfigProperties.getManagerDn())
          .managerPassword(ldapConfigProperties.getManagerPassword())
          .url(ldapConfigProperties.getUrl())
          .and()
          .userDetailsContextMapper(ldapContextMapper);

The ldapContextMapper is an instance of a custom class called LdapUserContextMapper that implements UserDetailsContextMapper.

Inside mapUserFromContext() I use the DirContextOperations to retrieve several attributes from the LDAP user to construct a concrete User POJO. However, I just can't get access to operational attributes like memberOf. I tried every solution I could possible find on the web, but nothing seems to have worked.

For instance, ctx.getObjectAttributes("memberOf") returns null. Attempting to call ctx.search("", "", searchControls) with custom SearchControls with SUBTREE_SCOPE yields a not implemented exception from DirContextAdapter.

Any ideas?

1

1 Answers

0
votes

I eventually ended up instantiating my own ContextSource and then using a custom ObjectPostProcessor, just as described in this issue.