@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, IPeople¶
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¶
User Messages (Mail)¶
See Messages
User OneDrive¶
See OneDrive