public synchronized void grantAdminPrivilege(UserEntity userEntity) {
    final PrivilegeEntity adminPrivilege = new PrivilegeEntity();
    adminPrivilege.setPermission(permissionDAO.findAmbariAdminPermission());
    adminPrivilege.setPrincipal(userEntity.getPrincipal());
    adminPrivilege.setResource(resourceDAO.findAmbariResource());
    if (!userEntity.getPrincipal().getPrivileges().contains(adminPrivilege)) {
      privilegeDAO.create(adminPrivilege);
      userEntity.getPrincipal().getPrivileges().add(adminPrivilege);
      principalDAO.merge(userEntity.getPrincipal()); //explicit merge for Derby support
      userDAO.merge(userEntity);
    }
  }
Grants Ambari Administrator privilege to provided user.

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