Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to search users in Microsoft Graph SDK with C#?

In my C# application, I am using Microsoft Graph SDK with Azure AD implementation.

Please suggest me how to search users in my organisations (global contacts) based on search parameters . For example , if "Raj" is the search parameter, I should be able to get all users with their name contains "Raj" or email address contains "Raj". I found this method to get all users - "graphClient.Users.Request().GetAsync();". but, with this method limited response, I am not getting what exactly I want to search.

Thanks, Shashidhar

like image 481
Shashi1988 Avatar asked Oct 24 '18 13:10

Shashi1988


People also ask

How do I find my user ID for graph API?

You can get the user information for the signed-in user by replacing /users/{id | userPrincipalName} with /me .

How do I check permissions on a graph API?

If users are logging in with work or school accounts (Azure AD), you can just look inside the access token to see a list of permissions like User. Read or Files. ReadWrite.


1 Answers

Adding to the previous answer: to accomplish this through the Graph C# SDK, use the Filter() method:

graphClient.Users.Request().Filter("startsWith(displayName, 'k')").GetAsync()

You can use other methods on the request to customize the request, e.g. Select(), etc.

like image 64
Peter Ciszewski Avatar answered Nov 08 '22 12:11

Peter Ciszewski