This post will explain how to use the .Net Microsoft Graph SDK in order to get users. This article is assuming that you have already gotten an Access Token using ADAL .NET. In order to learn more on how to get the Adal .NET token, please reference :
How to Use the ADAL .NET library to Acquire a Token Interactively in a Console Application (Authorization Code Flow) Link
Warning Regarding Microsoft Graph SDK
The Microsoft Graph SDK isn’t updated as frequently as the Microsoft Graph API, which makes the Microsoft Graph SDK lag behind a bit. The most effective way to keep up with the Microsoft Graph API is to utilize the HTTPClient, and then parse the response body accordingly. If you would like to utilize the data structures and requests predefined in the Microsoft Graph SDK that is fine, however know that the SDK will not always be up to date with the Microsoft Graph API.
Installing the MSFT Graph SDK NuGet
In order to install this SDK, please go to your project management and then go to browse. Then look up Microsoft.Graph. This NuGet Package is shown in the picture below.
It is the Microsoft.Graph library.
Making Calls Using the Microsoft Graph SDK
In order to make calls to the Microsoft Graph SDK, you will need to get the Access token as shown in the other post on utilizing ADAL .net library to acquire a token. Once the access token has been acquired, you will create the graphserviceclient, setting the header of the request message as the access token. This is shown in the github gist below.
In the example, we get use the object in the graphserviceclient Users, which has a request call, which has the HTTP request call within, which can be called by using the .getAsync().getAwaiter().getResult() method chain.
In order to set the OData parameters, you can add them after the request() call.
Expand, Skip, Top, OrderBy, and Filter are also supported via the client library when supported by the Microsoft Graph service for the request type.
For more information, please refer to the documentation for the MSFT Graph SDK here: https://github.com/microsoftgraph/msgraph-sdk-dotnet/blob/dev/docs/overview.md
In order to page through the results, you will have to utilize the call : users.NextPageRequest.GetAsync().GetAwaiter().GetResult();
Where users is the GraphServiceClient.