class AmbariLdapDataPopulator {

  protected LdapUserDto getLdapUserByMemberAttr(String memberAttributeValue) {
    LdapServerProperties ldapServerProperties = getLdapProperties();
    Set<LdapUserDto> filteredLdapUsers;

    memberAttributeValue = getUniqueIdByMemberPattern(memberAttributeValue,
        ldapServerProperties.getSyncUserMemberReplacePattern());
    Filter syncMemberFilter = createCustomMemberFilter(memberAttributeValue,
        ldapServerProperties.getSyncUserMemberFilter());

    if (memberAttributeValue != null && syncMemberFilter != null) {
      LOG.trace("Use custom filter '{}' for getting member user with default baseDN ('{}')",
          syncMemberFilter.encode(), ldapServerProperties.getBaseDN());
      filteredLdapUsers = getFilteredLdapUsers(ldapServerProperties.getBaseDN(), syncMemberFilter);
    } else if (memberAttributeValue != null && isMemberAttributeBaseDn(memberAttributeValue)) {
      LOG.trace("Member can be used as baseDn: {}", memberAttributeValue);
      Filter filter = new EqualsFilter(OBJECT_CLASS_ATTRIBUTE, ldapServerProperties.getUserObjectClass());
      filteredLdapUsers = getFilteredLdapUsers(memberAttributeValue, filter);
    } else {
      LOG.trace("Member cannot be used as baseDn: {}", memberAttributeValue);
      Filter filter = new AndFilter()
          .and(new EqualsFilter(OBJECT_CLASS_ATTRIBUTE, ldapServerProperties.getUserObjectClass()))
          .and(new EqualsFilter(ldapServerProperties.getUsernameAttribute(), memberAttributeValue));
      filteredLdapUsers = getFilteredLdapUsers(ldapServerProperties.getBaseDN(), filter);
    }
    return (filteredLdapUsers.isEmpty()) ? null : filteredLdapUsers.iterator().next();
  }

  @Inject public  AmbariLdapDataPopulator(Provider<AmbariLdapConfiguration> configurationProvider, Users users);

}