Java Code Examples for org.springframework.ldap.core.support.LdapContextSource#setUrl()

The following examples show how to use org.springframework.ldap.core.support.LdapContextSource#setUrl() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: LdapManager.java    From blackduck-alert with Apache License 2.0 6 votes vote down vote up
public Optional<LdapAuthenticationProvider> createAuthProvider(FieldAccessor configuration) throws AlertConfigurationException {
    try {
        boolean enabled = configuration.getBooleanOrFalse(AuthenticationDescriptor.KEY_LDAP_ENABLED);
        if (!enabled) {
            return Optional.empty();
        }
        LdapContextSource ldapContextSource = new LdapContextSource();

        String ldapServer = configuration.getStringOrEmpty(AuthenticationDescriptor.KEY_LDAP_SERVER);
        String managerDN = configuration.getStringOrEmpty(AuthenticationDescriptor.KEY_LDAP_MANAGER_DN);
        String managerPassword = configuration.getStringOrEmpty(AuthenticationDescriptor.KEY_LDAP_MANAGER_PWD);
        String ldapReferral = configuration.getStringOrEmpty(AuthenticationDescriptor.KEY_LDAP_REFERRAL);
        if (StringUtils.isNotBlank(ldapServer)) {
            ldapContextSource.setUrl(ldapServer);
            ldapContextSource.setUserDn(managerDN);
            ldapContextSource.setPassword(managerPassword);
            ldapContextSource.setReferral(ldapReferral);
            ldapContextSource.setAuthenticationStrategy(createAuthenticationStrategy(configuration));
        }
        ldapContextSource.afterPropertiesSet();
        return Optional.of(updateAuthenticationProvider(configuration, ldapContextSource));
    } catch (IllegalArgumentException ex) {
        throw new AlertConfigurationException("Error creating LDAP Context Source", ex);
    }
}
 
Example 2
Source File: LDAPIdentityServiceImplTest.java    From rice with Educational Community License v2.0 6 votes vote down vote up
@BeforeClass
public static void startLDAPServer() throws Exception {
    LdapTestUtils.startApacheDirectoryServer(PORT, baseName.toString(), "test", PRINCIPAL, CREDENTIALS, null);
    LdapContextSource contextSource = new LdapContextSource();
    contextSource.setUrl("ldap://127.0.0.1:" + PORT);
    contextSource.setUserDn("");
    contextSource.setPassword("");
    contextSource.setPooled(false);
    contextSource.afterPropertiesSet();

    // Create the Sprint LDAP template
    LdapTemplate template = new LdapTemplate(contextSource);

    // Clear out any old data - and load the test data
    LdapTestUtils.cleanAndSetup(template.getContextSource(), baseName, new ClassPathResource("ldap/testdata.ldif"));
    System.out.println("____________Started LDAP_________");
}
 
Example 3
Source File: LdapCredentialsAuthenticator.java    From ob1k with Apache License 2.0 6 votes vote down vote up
/**
 * This constructor creates a LdapCredentialsAuthenticator that authenticates against an LDAP server
 * that does not support anonymous requests
 *
 * @param ldapHost    the LDAP server host
 * @param ldapPort    the LDAP server port
 * @param usersOuPath the path for the organizational unit under which users are found
 * @param userDn      the distinguished name for the connection
 * @param password    the password for the connection
 */
public LdapCredentialsAuthenticator(final String ldapHost,
                                    final int ldapPort,
                                    final String usersOuPath,
                                    final String userDn,
                                    final String password) {
  Assert.hasText(ldapHost, "Invalid ldapHost");
  Assert.isTrue(ldapPort > 0);
  Assert.hasText(usersOuPath, "Invalid usersOuPath");
  Assert.hasText(userDn, "Invalid userDn");
  Assert.hasText(password, "Invalid password");

  final LdapContextSource contextSource = new LdapContextSource();
  contextSource.setUrl("ldap://" + ldapHost + ":" + ldapPort);
  contextSource.setBase(usersOuPath);
  contextSource.setUserDn(userDn);
  contextSource.setPassword(password);
  contextSource.afterPropertiesSet();

  ldapTemplate = new LdapTemplate(contextSource);
  this.id = calculateId(ldapHost, ldapPort, usersOuPath);
}
 
Example 4
Source File: BaseDAOTest.java    From geofence with GNU General Public License v2.0 6 votes vote down vote up
protected static void loadData() throws Exception
{
    // Bind to the directory
    LdapContextSource contextSource = new LdapContextSource();
    contextSource.setUrl("ldap://127.0.0.1:10389");
    contextSource.setUserDn("uid=admin,ou=system");
    contextSource.setPassword("secret");
    contextSource.setPooled(false);
    //contextSource.setDirObjectFactory(null);
    contextSource.afterPropertiesSet();

    // Create the Sprint LDAP template
    LdapTemplate template = new LdapTemplate(contextSource);

    // Clear out any old data - and load the test data
    LdapTestUtils.clearSubContexts(contextSource, LdapUtils.newLdapName("dc=example,dc=com"));
    LdapTestUtils.loadLdif(contextSource, new ClassPathResource("data.ldif"));
}
 
Example 5
Source File: LdapCredentialsAuthenticator.java    From ob1k with Apache License 2.0 6 votes vote down vote up
/**
 * This constructor creates a LdapCredentialsAuthenticator that authenticates against an LDAP server
 * that supports anonymous requests
 *
 * @param ldapHost    the LDAP server host
 * @param ldapPort    the LDAP server port
 * @param usersOuPath the path for the organizational unit under which users are found
 */
public LdapCredentialsAuthenticator(final String ldapHost,
                                    final int ldapPort,
                                    final String usersOuPath) {
  Assert.hasText(ldapHost, "Invalid ldapHost");
  Assert.isTrue(ldapPort > 0);
  Assert.hasText(usersOuPath, "Invalid usersOuPath");

  final LdapContextSource contextSource = new LdapContextSource();
  contextSource.setAnonymousReadOnly(true);
  contextSource.setUrl("ldap://" + ldapHost + ":" + ldapPort);
  contextSource.setBase(usersOuPath);
  contextSource.afterPropertiesSet();

  ldapTemplate = new LdapTemplate(contextSource);
  this.id = calculateId(ldapHost, ldapPort, usersOuPath);
}
 
Example 6
Source File: ContextSourceEc2InstanceLaunchingFactoryBean.java    From spring-ldap with Apache License 2.0 5 votes vote down vote up
@Override
protected final Object doCreateInstance(final String dnsName) throws Exception {
	Assert.hasText(userDn);
	LdapContextSource instance = new LdapContextSource();
	instance.setUrl("ldap://" + dnsName);
	instance.setUserDn(userDn);
	instance.setPassword(password);
	instance.setBase(base);
	instance.setPooled(pooled);
	setAdditionalContextSourceProperties(instance, dnsName);

	instance.afterPropertiesSet();
	return instance;
}
 
Example 7
Source File: TestContextSourceFactoryBean.java    From spring-ldap with Apache License 2.0 5 votes vote down vote up
protected Object createInstance() throws Exception {
       LdapTestUtils.startEmbeddedServer(port, defaultPartitionSuffix, defaultPartitionName);

       if (contextSource == null) {
           // If not explicitly configured, create a new instance.
           LdapContextSource targetContextSource = new LdapContextSource();
           if (baseOnTarget) {
               targetContextSource.setBase(defaultPartitionSuffix);
           }

           targetContextSource.setUrl("ldap://localhost:" + port);
           targetContextSource.setUserDn(principal);
           targetContextSource.setPassword(password);
           targetContextSource.setDirObjectFactory(dirObjectFactory);
           targetContextSource.setPooled(pooled);

           if (authenticationSource != null) {
               targetContextSource.setAuthenticationSource(authenticationSource);
           }
           targetContextSource.afterPropertiesSet();

           contextSource = targetContextSource;
       }

       Thread.sleep(1000);

       if (baseOnTarget) {
		LdapTestUtils.clearSubContexts(contextSource, LdapUtils.emptyLdapName());
	}
	else {
		LdapTestUtils.clearSubContexts(contextSource, LdapUtils.newLdapName(defaultPartitionSuffix));
	}

	if (ldifFile != null) {
           LdapTestUtils.loadLdif(contextSource, ldifFile);
	}

	return contextSource;
}
 
Example 8
Source File: TestContextSourceFactoryBean.java    From spring-ldap with Apache License 2.0 5 votes vote down vote up
protected ContextSource createInstance() throws Exception {
    LdapTestUtils.startEmbeddedServer(port,
            defaultPartitionSuffix, defaultPartitionName);

    if (contextSource == null) {
        // If not explicitly configured, create a new instance.
        LdapContextSource targetContextSource = new LdapContextSource();
        if (baseOnTarget) {
            targetContextSource.setBase(defaultPartitionSuffix);
        }

        targetContextSource.setUrl("ldap://localhost:" + port);
        targetContextSource.setUserDn(principal);
        targetContextSource.setPassword(password);
        targetContextSource.setDirObjectFactory(dirObjectFactory);
        targetContextSource.setPooled(pooled);

        if (authenticationSource != null) {
            targetContextSource.setAuthenticationSource(authenticationSource);
        }
        targetContextSource.afterPropertiesSet();

        contextSource = targetContextSource;
    }

    Thread.sleep(1000);

    if (baseOnTarget) {
        LdapTestUtils.clearSubContexts(contextSource, LdapUtils.emptyLdapName());
    }
    else {
        LdapTestUtils.clearSubContexts(contextSource, LdapUtils.newLdapName(defaultPartitionSuffix));
    }

    if (ldifFile != null) {
        LdapTestUtils.loadLdif(contextSource, ldifFile);
    }

    return contextSource;
}
 
Example 9
Source File: TestLdap.java    From spring-ldap with Apache License 2.0 5 votes vote down vote up
private static ContextSource getContextSource(String url, String username, String password) throws Exception {
    LdapContextSource contextSource = new LdapContextSource();
    contextSource.setUrl(url);
    contextSource.setUserDn(username);
    contextSource.setPassword(password);
    contextSource.setPooled(false);
    contextSource.afterPropertiesSet();

    return contextSource;
}
 
Example 10
Source File: TestSchemaToJava.java    From spring-ldap with Apache License 2.0 5 votes vote down vote up
@Before
public void setUp() throws Exception {
    // Create some basic converters and a converter manager
    converterManager = new ConverterManagerImpl();

    Converter ptc = new FromStringConverter();
    converterManager.addConverter(String.class, "", Byte.class, ptc);
    converterManager.addConverter(String.class, "", Short.class, ptc);
    converterManager.addConverter(String.class, "", Integer.class, ptc);
    converterManager.addConverter(String.class, "", Long.class, ptc);
    converterManager.addConverter(String.class, "", Double.class, ptc);
    converterManager.addConverter(String.class, "", Float.class, ptc);
    converterManager.addConverter(String.class, "", Boolean.class, ptc);

    Converter tsc = new ToStringConverter();
    converterManager.addConverter(Byte.class, "", String.class, tsc);
    converterManager.addConverter(Short.class, "", String.class, tsc);
    converterManager.addConverter(Integer.class, "", String.class, tsc);
    converterManager.addConverter(Long.class, "", String.class, tsc);
    converterManager.addConverter(Double.class, "", String.class, tsc);
    converterManager.addConverter(Float.class, "", String.class, tsc);
    converterManager.addConverter(Boolean.class, "", String.class, tsc);

    // Bind to the directory
    contextSource = new LdapContextSource();
    contextSource.setUrl("ldap://127.0.0.1:" + port);
    contextSource.setUserDn("");
    contextSource.setPassword("");
    contextSource.setPooled(false);
    contextSource.afterPropertiesSet();

    // Clear out any old data - and load the test data
    LdapTestUtils.cleanAndSetup(contextSource, baseName, new ClassPathResource("testdata.ldif"));
}
 
Example 11
Source File: LdapConfig.java    From metron with Apache License 2.0 5 votes vote down vote up
@Bean
public LdapTemplate ldapTemplate() {
  LdapContextSource contextSource = new LdapContextSource();

  contextSource.setUrl(environment.getProperty(LDAP_PROVIDER_URL_SPRING_PROPERTY));
  contextSource.setUserDn(environment.getProperty(LDAP_PROVIDER_USERDN_SPRING_PROPERTY));
  contextSource.setPassword(environment.getProperty(LDAP_PROVIDER_PASSWORD_SPRING_PROPERTY));
  contextSource.afterPropertiesSet();

  return new LdapTemplate(contextSource);
}
 
Example 12
Source File: LdapOperationsTest.java    From herd with Apache License 2.0 5 votes vote down vote up
@Test
public void testSearch()
{
    // Create and initialize an LDAP context source.
    LdapContextSource contextSource = new LdapContextSource();
    contextSource.setUrl(LDAP_URL);
    contextSource.setBase(LDAP_BASE);
    contextSource.setUserDn(LDAP_USER_DN);
    contextSource.setPassword(PASSWORD);
    contextSource.afterPropertiesSet();

    // Create an LDAP template.
    LdapTemplate ldapTemplate = new LdapTemplate(contextSource);

    // Create an LDAP query.
    LdapQuery ldapQuery = query().where((String) ConfigurationValue.LDAP_ATTRIBUTE_USER_ID.getDefaultValue()).is(USER_ID);

    // Create a subject matter expert contact details mapper.
    SubjectMatterExpertDaoImpl.SubjectMatterExpertContactDetailsMapper subjectMatterExpertContactDetailsMapper =
        new SubjectMatterExpertDaoImpl.SubjectMatterExpertContactDetailsMapper((String) ConfigurationValue.LDAP_ATTRIBUTE_USER_FULL_NAME.getDefaultValue(),
            (String) ConfigurationValue.LDAP_ATTRIBUTE_USER_JOB_TITLE.getDefaultValue(),
            (String) ConfigurationValue.LDAP_ATTRIBUTE_USER_EMAIL_ADDRESS.getDefaultValue(),
            (String) ConfigurationValue.LDAP_ATTRIBUTE_USER_TELEPHONE_NUMBER.getDefaultValue());

    // Gets information for the specified subject matter expert.
    List<SubjectMatterExpertContactDetails> result = ldapOperations.search(ldapTemplate, ldapQuery, subjectMatterExpertContactDetailsMapper);

    // Validate the results.
    assertEquals(
        Collections.singletonList(new SubjectMatterExpertContactDetails(USER_FULL_NAME, USER_JOB_TITLE, USER_EMAIL_ADDRESS, USER_TELEPHONE_NUMBER)),
        result);
}
 
Example 13
Source File: LdapConfiguration.java    From taskana with Apache License 2.0 5 votes vote down vote up
@Bean
@ConditionalOnMissingBean(LdapContextSource.class)
public LdapContextSource ldapContextSource() {
  LdapContextSource contextSource = new LdapContextSource();
  contextSource.setUrl(ldapServerUrl);
  contextSource.setBase(ldapBaseDn);
  contextSource.setUserDn(ldapBindDn);
  contextSource.setPassword(ldapBindPassword);
  return contextSource;
}
 
Example 14
Source File: TokenAuthenticationService.java    From heimdall with Apache License 2.0 5 votes vote down vote up
private LdapAuthenticationProvider ldapProvider(Ldap ldap) {

        LdapContextSource contextSource = new LdapContextSource();
        contextSource.setUrl(ldap.getUrl());
        contextSource.setUserDn(ldap.getUserDn());
        contextSource.setPassword(ldap.getPassword());
        contextSource.setReferral("follow");
        contextSource.afterPropertiesSet();

        LdapUserSearch ldapUserSearch = new FilterBasedLdapUserSearch(ldap.getSearchBase(), ldap.getUserSearchFilter(), contextSource);

        BindAuthenticator bindAuthenticator = new BindAuthenticator(contextSource);
        bindAuthenticator.setUserSearch(ldapUserSearch);
        return new LdapAuthenticationProvider(bindAuthenticator, populator);
    }
 
Example 15
Source File: LdapDataConfig.java    From Spring-5.0-Projects with MIT License 5 votes vote down vote up
@Bean
public ContextSource getLdapContextSrc() {
	LdapContextSource ldapContextSrc = new LdapContextSource();
	ldapContextSrc.setUrl(ldapUrls);
	ldapContextSrc.setUserDn(ldapManagerUserName);
	ldapContextSrc.setPassword(ldapManagerPwd);
	ldapContextSrc.setBase(ldapBase);
	ldapContextSrc.afterPropertiesSet();
	return ldapContextSrc;
}
 
Example 16
Source File: SubjectMatterExpertDaoImpl.java    From herd with Apache License 2.0 4 votes vote down vote up
@Override
public SubjectMatterExpertContactDetails getSubjectMatterExpertByKey(SubjectMatterExpertKey subjectMatterExpertKey)
{
    // Get LDAP specific configuration settings.
    final String ldapUrl = configurationHelper.getProperty(ConfigurationValue.LDAP_URL);
    final String ldapBase = configurationHelper.getProperty(ConfigurationValue.LDAP_BASE);
    final String ldapUserDn = configurationHelper.getProperty(ConfigurationValue.LDAP_USER_DN);
    final String credStashEncryptionContext = configurationHelper.getProperty(ConfigurationValue.CREDSTASH_HERD_ENCRYPTION_CONTEXT);
    final String ldapUserCredentialName = configurationHelper.getProperty(ConfigurationValue.LDAP_USER_CREDENTIAL_NAME);

    // Log configuration values being used to create LDAP context source.
    LOGGER.info("Creating LDAP context source using the following parameters: {}=\"{}\" {}=\"{}\" {}=\"{}\" {}=\"{}\" {}=\"{}\"...",
        ConfigurationValue.LDAP_URL.getKey(), ldapUrl, ConfigurationValue.LDAP_BASE.getKey(), ldapBase, ConfigurationValue.LDAP_USER_DN.getKey(),
        ldapUserDn, ConfigurationValue.CREDSTASH_HERD_ENCRYPTION_CONTEXT.getKey(), credStashEncryptionContext,
        ConfigurationValue.LDAP_USER_CREDENTIAL_NAME.getKey(), ldapUserCredentialName);

    // Retrieve LDAP user password from the credstash.
    String ldapUserPassword;
    try
    {
        ldapUserPassword = credStashHelper.getCredentialFromCredStash(credStashEncryptionContext, ldapUserCredentialName);
    }
    catch (CredStashGetCredentialFailedException e)
    {
        throw new IllegalStateException(e);
    }

    // Create and initialize an LDAP context source.
    LdapContextSource contextSource = new LdapContextSource();
    contextSource.setUrl(ldapUrl);
    contextSource.setBase(ldapBase);
    contextSource.setUserDn(ldapUserDn);
    contextSource.setPassword(ldapUserPassword);
    contextSource.afterPropertiesSet();

    // Create an LDAP template.
    LdapTemplate ldapTemplate = new LdapTemplate(contextSource);

    // Create an LDAP query.
    LdapQuery ldapQuery = query().where(configurationHelper.getProperty(ConfigurationValue.LDAP_ATTRIBUTE_USER_ID)).is(subjectMatterExpertKey.getUserId());

    // Create a subject matter expert contact details mapper.
    SubjectMatterExpertContactDetailsMapper subjectMatterExpertContactDetailsMapper =
        new SubjectMatterExpertContactDetailsMapper(configurationHelper.getProperty(ConfigurationValue.LDAP_ATTRIBUTE_USER_FULL_NAME),
            configurationHelper.getProperty(ConfigurationValue.LDAP_ATTRIBUTE_USER_JOB_TITLE),
            configurationHelper.getProperty(ConfigurationValue.LDAP_ATTRIBUTE_USER_EMAIL_ADDRESS),
            configurationHelper.getProperty(ConfigurationValue.LDAP_ATTRIBUTE_USER_TELEPHONE_NUMBER));

    // Gets information for the specified subject matter expert.
    List<SubjectMatterExpertContactDetails> subjectMatterExpertContactDetailsList =
        ldapOperations.search(ldapTemplate, ldapQuery, subjectMatterExpertContactDetailsMapper);

    // Return the results.
    return CollectionUtils.isNotEmpty(subjectMatterExpertContactDetailsList) ? subjectMatterExpertContactDetailsList.get(0) : null;
}
 
Example 17
Source File: SchemaToJavaAdITest.java    From spring-ldap with Apache License 2.0 4 votes vote down vote up
@Before
public void setUp() throws Exception {
    // Create some basic converters and a converter manager
    converterManager = new ConverterManagerImpl();

    Converter ptc = new FromStringConverter();
    converterManager.addConverter(String.class, "", Byte.class, ptc);
    converterManager.addConverter(String.class, "", Short.class, ptc);
    converterManager.addConverter(String.class, "", Integer.class, ptc);
    converterManager.addConverter(String.class, "", Long.class, ptc);
    converterManager.addConverter(String.class, "", Double.class, ptc);
    converterManager.addConverter(String.class, "", Float.class, ptc);
    converterManager.addConverter(String.class, "", Boolean.class, ptc);

    Converter tsc = new ToStringConverter();
    converterManager.addConverter(Byte.class, "", String.class, tsc);
    converterManager.addConverter(Short.class, "", String.class, tsc);
    converterManager.addConverter(Integer.class, "", String.class, tsc);
    converterManager.addConverter(Long.class, "", String.class, tsc);
    converterManager.addConverter(Double.class, "", String.class, tsc);
    converterManager.addConverter(Float.class, "", String.class, tsc);
    converterManager.addConverter(Boolean.class, "", String.class, tsc);

    // Bind to the directory
    contextSource = new LdapContextSource();
    contextSource.setUrl("ldaps://127.0.0.1:" + port);
    contextSource.setUserDn(USER_DN);
    contextSource.setPassword(PASSWORD);
    contextSource.setPooled(false);
    contextSource.setBase("dc=261consulting,dc=local");
    HashMap<String, Object> baseEnvironment = new HashMap<String, Object>() {{
        put("java.naming.ldap.attributes.binary", "thumbnailLogo replPropertyMetaData partialAttributeSet registeredAddress userPassword telexNumber partialAttributeDeletionList mS-DS-ConsistencyGuid attributeCertificateAttribute thumbnailPhoto teletexTerminalIdentifier replUpToDateVector dSASignature objectGUID");
    }};
    contextSource.setBaseEnvironmentProperties(baseEnvironment);
    contextSource.afterPropertiesSet();

    ldapTemplate = new LdapTemplate(contextSource);

    cleanup();

    DirContextAdapter ctx = new DirContextAdapter("cn=William Hartnell,cn=Users");
    ctx.setAttributeValues("objectclass", new String[]{"person","inetorgperson","organizationalperson","top"});
    ctx.setAttributeValue("cn", "William Hartnell");
    ctx.addAttributeValue("description", "First Doctor");
    ctx.addAttributeValue("description", "Grumpy");
    ctx.addAttributeValue("sn", "Hartnell");
    ctx.addAttributeValue("telephonenumber", "1");

    ldapTemplate.bind(ctx);
}
 
Example 18
Source File: ChoerodonAuthenticationProvider.java    From oauth-server with Apache License 2.0 4 votes vote down vote up
private boolean ldapAuthentication(Long organizationId, String loginName, String credentials) {
    LdapE ldap = ldapService.queryByOrgId(organizationId);
    if (ldap != null && ldap.getEnabled()) {
        LdapContextSource contextSource = new LdapContextSource();
        String url = ldap.getServerAddress() + ":" + ldap.getPort();
        int connectionTimeout = ldap.getConnectionTimeout();
        contextSource.setUrl(url);
        contextSource.setBase(ldap.getBaseDn());
        setConnectionTimeout(contextSource, connectionTimeout);
        contextSource.afterPropertiesSet();

        LdapTemplate ldapTemplate = new LdapTemplate(contextSource);
        //ad目录不设置会报错
        if (DirectoryType.MICROSOFT_ACTIVE_DIRECTORY.value().equals(ldap.getDirectoryType())) {
            ldapTemplate.setIgnorePartialResultException(true);
        }
        String userDn = null;
        boolean anonymousFetchFailed = false;

        AndFilter filter = getLoginFilter(ldap, loginName);
        try {
            List<String> names =
                    ldapTemplate.search(
                            query()
                                    .searchScope(SearchScope.SUBTREE)
                                    .filter(filter),
                            new AbstractContextMapper() {
                                @Override
                                protected Object doMapFromContext(DirContextOperations ctx) {
                                    return ctx.getNameInNamespace();
                                }
                            });
            userDn = getUserDn(names, ldap.getLoginNameField(), loginName);
        } catch (Exception e) {
            anonymousFetchFailed = true;
            LOG.error("ldap anonymous search failed, filter {}, exception {}", filter, e);
        }
        if (anonymousFetchFailed) {
            userDn = accountAsUserDn2Authentication(loginName, ldap, contextSource, filter);
        }
        if (userDn == null) {
            LOG.error("can not get userDn by filter {}, login failed", filter);
            return false;
        }
        return authentication(credentials, contextSource, userDn);
    } else {
        throw new AuthenticationServiceException(LoginException.LDAP_IS_DISABLE.value());
    }
}