0

I have created a custom LdapUserDetailsMapper class to map extended properties to a custom UserDetails class that contains extra properties for things like displayName, telephoneNumber and department to name a few. I managed to populate these properties by accessing the properties against the DirContextOperation, i.e.

res.givenName = ctx.getStringAttribute("givenName");

I do not wish to hard-code this however and would like to have these properties configurable, which is fine, though I also want to use LDAP expressions to return a value resulting from that expression, i.e.

res.givenName = ctx.getStringAttribute("givenName + ' ' + sn");

This of course does not work. I could manually parse the pattern and retrieve the components prior to any concatenation but this sounds like work that I imagine the framework could already provide.

Brett Ryan
  • 26,937
  • 30
  • 128
  • 163

1 Answers1

1

One possible solution I would imagine could work is to use the Spring Expression Language. Implement your own EvaluationContext that takes a DirContextOperations instance as root object and forwards porperty reads to its getStringAttribute() method. The expressions in this case wouldn't exactly be LDAP expressions, but I guess SpEL is more powerful, so it might be even better.

ig0774
  • 39,669
  • 3
  • 55
  • 57
zagyi
  • 17,223
  • 4
  • 51
  • 48