Skip to content

@pnp/graph/users

Users are Azure Active Directory objects representing users in the organizations. They represent the single identity for a person across Microsoft 365 services.

You can learn more about Microsoft Graph users by reading the Official Microsoft Graph Documentation.

IUsers, IUser

Invokable Banner Selective Imports Banner

Scenario Import Statement
Selective 1 import { graph } from "@pnp/graph";
import "@pnp/graph/users";
Preset: All import { graph } from "@pnp/sp/presets/all";

Current User

import { graph } from "@pnp/graph";
import "@pnp/graph/users";

const currentUser = await graph.me();

Get All Users in the Organization

import { graph } from "@pnp/graph";
import "@pnp/graph/users";

const allUsers = await graph.users();

Get a User by email address (or user id)

import { graph } from "@pnp/graph";
import "@pnp/graph/users";

const matchingUser = await graph.users.getById('jane@contoso.com')();

Update Current User

import { graph } from "@pnp/graph";
import "@pnp/graph/users";

await graph.me.update({
    displayName: 'John Doe'
});

People

import { graph } from "@pnp/graph";
import "@pnp/graph/users";

const people = await graph.me.people();

// get the top 3 people
const people = await graph.me.people.top(3)();
spacer