private DirContextOperations setAmbariAdminAttr(DirContextOperations user, LdapServerProperties ldapServerProperties) {
    String baseDn = ldapServerProperties.getBaseDN().toLowerCase();
    String groupBase = ldapServerProperties.getGroupBase().toLowerCase();
    final String groupNamingAttribute =
        ldapServerProperties.getGroupNamingAttr();
    final String adminGroupMappingMemberAttr = ldapServerProperties.getAdminGroupMappingMemberAttr();

    //If groupBase is set incorrectly or isn't set - search in BaseDn
    int indexOfBaseDn = groupBase.indexOf(baseDn);
    groupBase = indexOfBaseDn <= 0 ? "" : groupBase.substring(0, indexOfBaseDn - 1);

    String memberValue = StringUtils.isNotEmpty(adminGroupMappingMemberAttr)
        ? user.getStringAttribute(adminGroupMappingMemberAttr) : user.getNameInNamespace();
    LOG.debug("LDAP login - set '{}' as member attribute for adminGroupMappingRules", memberValue);

    String setAmbariAdminAttrFilter = resolveAmbariAdminAttrFilter(ldapServerProperties, memberValue);
    LOG.debug("LDAP login - set admin attr filter: {}", setAmbariAdminAttrFilter);

    AttributesMapper attributesMapper = attrs -> attrs.get(groupNamingAttribute).get();

    LdapTemplate ldapTemplate = new LdapTemplate((getContextSource()));
    ldapTemplate.setIgnorePartialResultException(true);
    ldapTemplate.setIgnoreNameNotFoundException(true);

    @SuppressWarnings("unchecked")
    List<String> ambariAdminGroups = ldapTemplate.search(groupBase, setAmbariAdminAttrFilter, attributesMapper);

    //user has admin role granted, if user is a member of at least 1 group,
    // which matches the rules in configuration
    if (ambariAdminGroups.size() > 0) {
      user.setAttributeValue(AMBARI_ADMIN_LDAP_ATTRIBUTE_KEY, true);
    }

    return user;
  }
Checks weather user is a member of ambari administrators group in LDAP. If
yes, sets user's ambari_admin attribute to true

@param user the user details
@return the updated user details
ambari-server/src/main/java/org/apache/ambari/server/security/authorization/AmbariLdapBindAuthenticator.java