Graph API for User fetch

asked 2022-06-27T13:06:07.197+00:00
Anand Patil 91 Reputation points

I have an Azure AD B2C Tenant which I have configured with an external identity provider. In the identity provider configuration, I have mapped 'User ID' field with an attribute 'subject' from the claims.
Now, I am trying to use Microsoft Graph API to fetch users from my B2C tenant using this 'User ID' field. I am able to fetch users basis their name / displayName and similar attributes. However, I need to do it using 'User ID' field.
Is there a way to achieve this ?

I have tried the below method for fetching users using name and it works fine, however need correct attribute name to be used in the filter for the 'User ID' field -

this.graphClient.Users.Request().Filter($"startsWith(displayName, '{nameValue}')")
.Select(e => new
{
e.DisplayName,
e.Id,
e.Identities,
e.UserPrincipalName
})
.GetAsync();

Is it because I have tried to use 'User Flow' in this scenario for my sign-in? Is this possible to do using 'Custom Policy' ?

Awaiting responses. Thanks in advance.

Azure Active Directory External Identities
Microsoft Graph Users API
Microsoft Graph Users API
A Microsoft API that allows you to build compelling app experiences based on users, their relationships with other users and groups, and the resources they access for example their mails, calendars, files, administrative roles, group memberships.
545 questions
Microsoft Graph Identity API
Microsoft Graph Identity API
A Microsoft API to access Azure Active Directory (Azure AD) resources to enable scenarios like managing administrator (directory) roles, inviting external users to an organization, and, if you are a Cloud Solution Provider (CSP), managing your customer's data.
257 questions
No comments
{count} votes

Accepted answer
  1. answered 2022-06-28T08:12:53.717+00:00
    Carl Zhao_MSFT 18,056 Reputation points Microsoft Employee

    Hi @Anand Patil

    Do you want to filter users by user id? Please try the following code snippet:

    this.graphClient.Users.Request().Filter($"id eq '{id value}'")  
    .Select(e => new  
    {  
    e.DisplayName,  
    e.Id,  
    e.Identities,  
    e.UserPrincipalName  
    })  
    .GetAsync();  
    

    If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.


0 additional answers

Sort by: Most helpful