public synchronized boolean isUserCanBeRemoved(UserEntity userEntity) {
    List<PrincipalEntity> adminPrincipals = principalDAO.findByPermissionId(PermissionEntity.AMBARI_ADMINISTRATOR_PERMISSION);
    Set<UserEntity> userEntitysSet = new HashSet<>(userDAO.findUsersByPrincipal(adminPrincipals));
    return (userEntitysSet.contains(userEntity) && userEntitysSet.size() < 2) ? false : true;
  }
Performs a check if the user can be removed. Do not allow removing all admins from database.

@param userEntity user to be checked
@return true if user can be removed
ambari-server/src/main/java/org/apache/ambari/server/security/authorization/Users.java