1

In my personal Azure account, I migrated some users from a Windows Server AD, and some were created directly in Azure AD, and some users came from Microsoft Personal accounts. I have been able to display these users in a Windows Desktop app using Microsoft Graph - similar to what we see in Azure Portal (as shown below). Moreover, as shown below, the Source of user list in Azure portal tells you whether a user was migrated from Windows Server AD or not. But I have not been able to find a way to programmatically find out if the user was migrated from Windows Server AD or not. Question: Is there an MS Graph API or some other way to programmatically find out out if user was migrated from Windows Server AD or not?

Remark: Although I am using UWP, but it should not matter. A suggestion can be related to any type of app as long as the language is C#.

To get users list:

// Get the Graph client from the provider
var graphClient = ProviderManager.Instance.GlobalProvider.Graph;

 var users = await graphClient.Users.Request()
    .Select("displayName, userPrincipalName, userType")
     .GetAsync();

Users shown in Azure Portal [For Source Column in my Windows Desktop app, I need to determine whether user was migrated from Windows Server AD or not]:

enter image description here

nam
  • 21,967
  • 37
  • 158
  • 332

1 Answers1

1

I think you can distinguish the user from(or not from) Windows Server AD by the fields start with onPremises. If the user comes from Windows Server AD, the fields onPremises... will not be null. If not from Windows Server AD, the fields should be null. Please refer to below screenshot:

enter image description here

enter image description here

===================================Update==================================

We can use one of the fields which shown above(such as OnPremisesUserPrincipalName) to judge if the user from Windows Server AD or not.

Hury Shen
  • 14,948
  • 1
  • 9
  • 18
  • There are 26 such fields in [user resource type](https://learn.microsoft.com/en-us/graph/api/resources/user?view=graph-rest-1.0). I thought these would be too much to use in a criteria. For my needs, just using `OnPremisesUserPrincipalName` field should be suffice. However, I'm not getting the expected results. I've posted the issue [here](https://stackoverflow.com/q/63207643/1232087) in case if you have any suggestions/comments. – nam Aug 01 '20 at 16:44
  • The issue posted [here](https://stackoverflow.com/questions/63207643/ms-graph-linq-query-string-not-null-or-empty-issue) has now been resolved. If you can modify your above response based on my needs (described in my comment above), I will mark your above response as an `Answer`, as well - so the other users can also benefit with it. Readers pay more attention to a response if it's an accepted one. Thank you. – nam Aug 02 '20 at 14:12
  • Hi @nam I have improved my answer. – Hury Shen Aug 03 '20 at 03:00