public synchronized void revokeAdminPrivilege(UserEntity userEntity) {
    for (PrivilegeEntity privilege : userEntity.getPrincipal().getPrivileges()) {
      if (privilege.getPermission().getPermissionName().equals(PermissionEntity.AMBARI_ADMINISTRATOR_PERMISSION_NAME)) {
        userEntity.getPrincipal().getPrivileges().remove(privilege);
        principalDAO.merge(userEntity.getPrincipal()); //explicit merge for Derby support
        userDAO.merge(userEntity);
        privilegeDAO.remove(privilege);
        break;
      }
    }
  }
Revokes Ambari Administrator privileges from provided user.

@param userEntity the user
ambari-server/src/main/java/org/apache/ambari/server/security/authorization/Users.java