Skip to content

EmbeddedLdapAutoConfiguration not setting the base information into the LdapContextSource #11693

@vdubus

Description

@vdubus

Currently (as of version 2.0.0.M7), EmbeddedLdapAutoConfiguration isn't properly setting the base information from LdapContextSource using the value from spring.ldap.embedded.base-dn.
Because of that, we can't test our @repository classes using an embedded LDAP server without overriding this bean unless if we want to set the whole path for each @Entry.

I would suggest the following change inside of org.springframework.boot.autoconfigure.ldap.embedded.EmbeddedLdapAutoConfiguration#ldapContextSource:

	@Bean
	@DependsOn("directoryServer")
	@ConditionalOnMissingBean
	public ContextSource ldapContextSource() {
		LdapContextSource source = new LdapContextSource();
		if (hasCredentials(this.embeddedProperties.getCredential())) {
			source.setUserDn(this.embeddedProperties.getCredential().getUsername());
			source.setPassword(this.embeddedProperties.getCredential().getPassword());
		}
		source.setBase(this.embeddedProperties.getBaseDn()); // Add this line.
		source.setUrls(this.properties.determineUrls(this.environment));
		return source;
	}

This issue was already reported in the issue #10443 which was closed without fixing the problem.

Metadata

Metadata

Assignees

No one assigned

    Labels

    status: declinedA suggestion or change that we don't feel we should currently apply

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions