private void processLdapAdminGroupMappingRules(Set<MemberEntity> membershipsToCreate) {

    if (membershipsToCreate.isEmpty()) {
      LOG.debug("There are no new memberships for which to process administrator group mapping rules.");
      return;
    }

    AmbariLdapConfiguration ldapConfiguration = ldapConfigurationProvider.get();
    if (ldapConfiguration == null) {
      LOG.warn("The LDAP configuration is not available - no administrator group mappings will be processed.");
      return;
    }

    String adminGroupMappings = ldapConfiguration.groupMappingRules();
    if (Strings.isNullOrEmpty(adminGroupMappings)) {
      LOG.debug("There are no administrator group mappings to be processed.");
      return;
    }

    LOG.info("Processing admin group mapping rules [{}]. Membership entry count: [{}]", adminGroupMappings, membershipsToCreate.size());

    // parse the comma separated list of mapping rules
    Set<String> ldapAdminGroups = Sets.newHashSet(adminGroupMappings.split(","));

    // LDAP users to become ambari administrators
    Set<UserEntity> ambariAdminProspects = Sets.newHashSet();

    // gathering all the users that need to be ambari admins
    for (MemberEntity memberEntity : membershipsToCreate) {
      if (ldapAdminGroups.contains(memberEntity.getGroup().getGroupName())) {
        LOG.debug("Ambari admin user prospect: [{}] ", memberEntity.getUser().getUserName());
        ambariAdminProspects.add(memberEntity.getUser());
      }
    }

    // granting admin privileges to the admin prospects
    for (UserEntity userEntity : ambariAdminProspects) {
      LOG.info("Granting ambari admin roles to the user: {}", userEntity.getUserName());
      grantAdminPrivilege(userEntity.getUserId());
    }

  }
Executes batch queries to database to insert large amounts of LDAP data.

@param batchInfo DTO with batch information
ambari-server/src/main/java/org/apache/ambari/server/security/authorization/Users.java