Graph API for User fetch

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

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.

Microsoft Graph
Microsoft Graph
A Microsoft programmability model that exposes REST APIs and client libraries to access data on Microsoft 365 services.
12,452 questions
Microsoft Entra External ID
Microsoft Entra External ID
A modern identity solution for securing access to customer, citizen and partner-facing apps and services. It is the converged platform of Azure AD External Identities B2B and B2C. Replaces Azure Active Directory External Identities.
2,947 questions
0 comments No comments
{count} votes

Accepted answer
  1. CarlZhao-MSFT 43,011 Reputation points
    2022-06-28T08:12:53.717+00:00

    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

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.