Home > Software engineering >  Microsoft graph get user by email or Mail
Microsoft graph get user by email or Mail

Time:06-22

I need to query get a single user details through Microsoft graph by email id, can anyone help me I couldn't find it in MS docs.

var users = graphServiceClient.Users.Request().GetAsync().GetAwaiter().GetResult();

this brings only 100 users I need to get user by email so I can get specific user

CodePudding user response:

Pls try this code.

using Azure.Identity;
using Microsoft.Graph;

var scopes = new[] { "https://graph.microsoft.com/.default" };
var tenantId = "hanxia.onmicrosoft.com";
var clientId = "azure_ad_app_id";
var clientSecret = "client_secret";
var clientSecretCredential = new ClientSecretCredential(
    tenantId, clientId, clientSecret);
var graphClient = new GraphServiceClient(clientSecretCredential, scopes);
var temp = await graphClient.Users.Request().Filter("mail eq '[email protected]'").GetAsync();

When we want to do a filter in Ms graph api, we may firstly check if the target property support filter, for enter image description here

  • Related