public LdapBatchDto synchronizeAllLdapUsers(LdapBatchDto batchInfo, boolean collectIgnoredUsers) throws AmbariException {
    LOG.trace("Synchronize All LDAP users...");
    Set<LdapUserDto> externalLdapUserInfo = getExternalLdapUserInfo();
    Map<String, User> internalUsersMap = getInternalUsers();

    for (LdapUserDto userDto : externalLdapUserInfo) {
      String userName = userDto.getUserName();
      if (internalUsersMap.containsKey(userName)) {
        final User user = internalUsersMap.get(userName);
        if (user != null && !user.isLdapUser()) {
          if (LdapUsernameCollisionHandlingBehavior.SKIP == getConfiguration().syncCollisionHandlingBehavior()) {
            LOG.info("User '{}' skipped because it is local user", userName);
            batchInfo.getUsersSkipped().add(userDto);
          } else {
            batchInfo.getUsersToBecomeLdap().add(userDto);
            LOG.trace("Convert user '{}' to LDAP user.", userName);
          }
        } else if (collectIgnoredUsers) {
          batchInfo.getUsersIgnored().add(userDto);
        }
        internalUsersMap.remove(userName);
      } else {
        batchInfo.getUsersToBeCreated().add(userDto);
      }
    }
    for (Entry<String, User> internalUser : internalUsersMap.entrySet()) {
      if (internalUser.getValue().isLdapUser()) {
        LdapUserDto userDto = new LdapUserDto();
        userDto.setUserName(internalUser.getValue().getUserName());
        userDto.setDn(null);  // Setting to null since we do not know what the DN for this user was.
        batchInfo.getUsersToBeRemoved().add(userDto);
      }
    }

    return batchInfo;
  }
Performs synchronization of given sets of all users.

@param collectIgnoredUsers true, to collect the set of existing users that would normally be ignored;
                           false, to continue to ignore them
@throws AmbariException if synchronization failed for any reason
ambari-server/src/main/java/org/apache/ambari/server/security/ldap/AmbariLdapDataPopulator.java