I'm creating an extension to a user management application that maintains users in an OpenLDAP server for authentication (in addition to an internal database) using the Spring Data Ldap repositories as the application is already using Spring 5 and Spring Data repositories.
The basic User and Group repositories work for finding, creating and updating, with one exception: group membership, because the member attribute requires a full DN (distinguished name) and unfortunately the user repository's @Id key is a relative DN.
My Ldap base is "dc=example,dc=com" The UserRepository returns "cn=user1,ou=users" but I need the full DN: "cn=user1,ou=users,dc=example,dc=com"
The base name is loaded in a ContextSource from ApplicationConfig.java, but since the repositories are generated dynamically and I have defined only an interface, I don't know how to inject that or the property and write code using it.
I have not found any method that returns the full DN. I have found what looks like a solution through this question and the user admin example from Spring LDAP. However this involves falling back on the Spring LDAP LdapTemplate, which is a step back from the Spring Data LDAP repositories to a more generic query model. Also, I can't get the example to build or run by itself due to dependency conflicts, so I'm worried about the longevity of a solution that mixes Spring Data LDAP and Spring Ldap Templates.
What I'm looking for is any way to retrieve the full DN or the base name from within the User, Group or their repository classes, so that I can supply these when adding members to a group or looking for groups for a member.