Get list of users on Azure Active Directory using Microsoft Graph API
Documentation Links:
- Obtain a valid authentication token:
-
Navigate to
Azure Active Directory
-
Create a new
App registration


-
Add
API Permissionsfor the Graph resources you’d like to access-
Click on the newly created application


-
Add the following permissions

-
Click on
Add a permission -
Navigate to
Microsoft APIs->Microsoft Graph->Application permissions -
Search for
User
-
Click
User.Read.AllandUser.ReadBasic.All
-
Navigate to
Microsoft APIs->Microsoft Graph->Delegate permissions -
Search
User -
Click on
User.ReadandUser.ReadBasic.All->Add Permission -
Make sure to click
Grant admin consent
-
- Creating application
-
Navigate to
Certificates & Secretsand create aNew client secrets -
Copy the
Valueand paste it into notepad
-
Go back to
Overview -
Copy
Application (client) IDas well asDirectory (tenant) IDand paste them into notepad
-
Go to this GitHub repository to find the code:
https://github.com/omoinjm/azure-user-listOR
-
Create new Console Application:
dotnet new console -
Install the following packages:
dotnet add package DotNetEnv dotnet add package Microsoft.Graph.Auth --version 1.0.0-preview.7 dotnet add package Microsoft.Graph dotnet add package Microsoft.Identity.Client -
Insert code in Program.cs

-
Insert Environment Variables
