@Override
  public void grantRoleToUser(String roleName, String userName) throws AuthException {
    checkAdmin(userName, "Invalid operation, cannot grant role to administrator");
    Role role = roleManager.getEntity(roleName);
    if (role == null) {
      throw new AuthException(
          TSStatusCode.ROLE_NOT_EXIST, String.format(NO_SUCH_ROLE_EXCEPTION, roleName));
    }
    // the role may be deleted before it ts granted to the user, so a double check is necessary.
    userManager.grantRoleToUser(roleName, userName);
    role = roleManager.getEntity(roleName);
    if (role == null) {
      throw new AuthException(
          TSStatusCode.ROLE_NOT_EXIST, String.format(NO_SUCH_ROLE_EXCEPTION, roleName));
    }
  }
Checks if a user has admin privileges
iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/auth/authorizer/BasicAuthorizer.java