How to retrieve all Office 365 users in the same domain with C#?

By : Matt
Source: Stackoverflow.com
Question!

Microsoft provides a PowerShell command Get-Msoluser to retrieve all office 365 users. I don't want my application tied to PowerShell, so I want to write a C# function to do the work, unfortunately, there's not much information on this topic.

I looked in the Office 365 APIs Preview documentation, no such functionality; also I looked into the SharePoint Client Object Model, no such thing either.

Can this be done without PowerShell? Is there a SDK can do this?

By : Matt


Answers

Yes, you can use the Azure AD Graph Client Library. There are also a couple of samples in that link that will show you how to retrieve your user(s).

This library is available as a nuget package. https://www.nuget.org/packages/Microsoft.Azure.ActiveDirectory.GraphClient/1.0.2



This video can help you solving your question :)
By: admin