protected void addLdapGroup(LdapBatchDto batchInfo, Map<String, Group> internalGroupsMap, LdapGroupDto groupDto) {
    String groupName = groupDto.getGroupName();
    if (internalGroupsMap.containsKey(groupName)) {
      final Group group = internalGroupsMap.get(groupName);
      if (!group.isLdapGroup()) {
        batchInfo.getGroupsToBecomeLdap().add(groupDto);
        LOG.trace("Convert group '{}' to LDAP group.", groupName);
      }
      internalGroupsMap.remove(groupName);
      batchInfo.getGroupsProcessedInternal().add(groupDto);
    } else {
      if (!batchInfo.getGroupsProcessedInternal().contains(groupDto)) {
        batchInfo.getGroupsToBeCreated().add(groupDto);
      }
    }
  }
Removes synced users which are not present in any of group.

@throws AmbariException
ambari-server/src/main/java/org/apache/ambari/server/security/ldap/AmbariLdapDataPopulator.java