Creating custom domain objects from LDAP entries and vice versa is a common pattern. Ldaptive provides an API for mapping an LdapEntry to any Object provided that object is properly annotated. This support is provided in a separate library that is available in the jars directory of the latest download.
Or included as a maven dependency:
The interface for ldap entry mapper looks like:
There are two annotations that describe the relationship between your object and an LDAP entry, @Entry and @Attribute. The @Entry annotation is a class level annotation that contains a DN and all the attributes for the entry. The following sample object demonstrates how to use these annotations.
DefaultLdapEntryMapper
Ldaptive provides a default implementation of the the LdapEntryMapper that supports the following types:
Boolean
Double
Float
Integer
Long
Short
String
byte[]
char[]
Certificate
Calendar (ZonedDateTime in v1.2)
UUID
Collections and arrays are supported, but property nesting is not. Only simple Java beans should be used with this ldap entry mapper.
SpringLdapEntryMapper
Ldaptive provides another implementation of LdapEntryMapper that can leverage SPEL for bean property resolution. This allows the conversion of LDAP data for more complex object graphs. The syntax for the @Attribute property is the SPEL expression. Note that the ldaptive-beans pom lists spring as an optional dependency, so if you’re using maven then you’ll have the declare the spring dependency.