spacer
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.

More information can be found in the official Graph documentation:

IUsers, IUser, IPeople

Invokable Banner Selective Imports Banner

Current User

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

const graph = graphfi(...);

const currentUser = await graph.me();

Get Users in the Organization

If you want to get all users you will need to use paging

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

const graph = graphfi(...);

const allUsers = await graph.users();

Get a User by email address (or user id)

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

const graph = graphfi(...);

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

User Properties

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

const graph = graphfi(...);

await graph.me.memberOf();
await graph.me.transitiveMemberOf();

Update Current User

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

const graph = graphfi(...);

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

People

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

const graph = graphfi(...);

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

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

Manager

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

const graph = graphfi(...);

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

Direct Reports

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

const graph = graphfi(...);

const reports = await graph.me.directReports();

Photo

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

const graph = graphfi(...);

const currentUser = await graph.me.photo();
const specificUser = await graph.users.getById('jane@contoso.com').photo();

User Photo Operations

See Photos

User Presence Operation

See Cloud Communications

User Messages (Mail)

See Messages

User OneDrive

See Files