Skip to content

LdapConnectionDetails Autoconfigure With Mulitple LDAP Connections #50748

@Dex-too

Description

@Dex-too

I apologize if this shouldn't be an issue, but this seems to fit somewhere between question, bug and enhancement, depending on the design opinions of the creators of this code.

I have a project that is using multiple LDAP connections, some for querying data, some for writing data. I included the spring-boot-starter-data-ldap dependency on my project to get the series of dependencies I need, but this also brings in the Spring Boot LDAP autoconfiguration. Maybe I shouldn't be using the Spring Boot starter for this then, and should instead specify all of the other dependencies I need individually to get the nice package this start gives me but without getting the autoconfiguration, but that seems to go against one of the purposes of these Spring Boot starters. (This is the question part of this issue that may short circuit the rest.)

The Spring Boot LDAP autoconfigure doesn't benefit me with multiple LDAP connections. As soon as it sees the additional connections, it bails on auto-configuring the primary connection. That's fine, I'll just recreate the configuration myself, using the standard "spring.ldap" properties in the usual application.yaml file. To do that I create an LdapProperties and LdapContextSource configuration. In the LdapContextSource configuration, I set the connection information directly from the LdapProperties. Because of this, I never use the LdapConnectionDetails wrapper object used in the autoconfiguration.

This is where my problem occurs. The Spring Boot autoconfigure still tries to create the LdapConnectionDetails bean despite it not being used anywhere (this is potentially the bug part of the request), but fails because there are multiple properties objects to use, one for each of the connections I have. So now I have to create this object just to have it thrown away and never used (or to then modify my context source code to pull from the wrapper instead of the properties directly, but that seems extraneous). It would be nice if this wasn't necessary (this is the enhancement part of this issue).

Further, when I try to create this bean configuration (using a qualifier to specify which properties I want it to use), I realize there is no public implementation wrapper of this interface, so I have to create a small/simple wrapper class that won't be used, in order to implement this interface, in order to stop the autoconfiguration from erroring on the multiple connections I have. If an implementation of this interface is required by the autoconfiguration (effectively), could you at least provide a simple public implementation wrapper that can be used to jump through this step, not unlike the package-private one that already exists? (This is the other enhancement part of this issue.)

Alternatively, is there a way to tell the Spring Boot autoconfigurations which qualifiers to use for their objects when the autoconfiguration runs, so I don't need to re-implement that configuration and can leverage the autoconfiguration functionality? (I believe this is a "no", but I ask in the hopes that maybe I missed something or that this could become a reality some day.)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions