class DefaultLdapConfigurationService implements LdapConfigurationService {

  @Override
  public String checkUserAttributes(String testUserName, String testPassword, AmbariLdapConfiguration ambariLdapConfiguration) throws AmbariLdapException {
    String userDn;
    try {
      LOGGER.info("Checking user attributes for user [{}] ...", testUserName);

      // set up a filter based on the provided attributes
      String filter = FilterBuilder.and(
        FilterBuilder.equal(SchemaConstants.OBJECT_CLASS_AT, ambariLdapConfiguration.userObjectClass()),
        FilterBuilder.equal(ambariLdapConfiguration.userNameAttribute(), testUserName))
        .toString();

      LOGGER.info("Searching for the user: [{}] using the search filter: [{}]", testUserName, filter);
      userDn = ldapConnectionTemplateFactory.create(ambariLdapConfiguration).searchFirst(new Dn(ambariLdapConfiguration.userSearchBase()), filter, SearchScope.SUBTREE, getUserDnNameEntryMapper(ambariLdapConfiguration));

      if (null == userDn) {
        LOGGER.info("Could not find test user based on the provided configuration. User attributes may not be complete or the user may not exist.");
        throw new AmbariLdapException("Could not find test user based on the provided configuration. User attributes may not be complete or the user may not exist.");
      }
      LOGGER.info("Attribute validation succeeded. Filter: [{}]", filter);


    } catch (Exception e) {

      LOGGER.error("User attributes validation failed.", e);
      throw new AmbariLdapException(e.getMessage(), e);

    }
    return userDn;
  }

  @Inject public  DefaultLdapConfigurationService();

}