C# to find if a user was migrated from Windows Server AD to Microsoft Azure

大兔子大兔子 提交于 2020-08-10 01:16:45

问题


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]:


回答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:

===================================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.



来源:https://stackoverflow.com/questions/63182729/c-sharp-to-find-if-a-user-was-migrated-from-windows-server-ad-to-microsoft-azure

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!