I'm working on a desktop application which accesses EntraID via the c# Graph API SDK.
The application monitors users logged into the device. Logged in user accounts are received as 'AzureAD\UserName'.
So for a logged in user account, 'AzureAD\JohnSmith' What I want to do is find the corresponding User entity 'John Smith' in Entra ID.
I guess what is needed is an Entra user attribute/property which holds the AzureAD account name 'Azuread\JohnSmith' and use this to query Entra via the Graph API.
I've searched the Entra Admin Centre, but cannot find an attribute which holds the AzureAD account name for any users in my test tenant.
Microsoft obviously do this mapping of AzureAD Account to Entra User entity internally, so I am hoping there is a way to do this.
I'd be grateful for any pointers or suggestions.
Thanks John
I'm working on a desktop application which accesses EntraID via the c# Graph API SDK.
The application monitors users logged into the device. Logged in user accounts are received as 'AzureAD\UserName'.
So for a logged in user account, 'AzureAD\JohnSmith' What I want to do is find the corresponding User entity 'John Smith' in Entra ID.
I guess what is needed is an Entra user attribute/property which holds the AzureAD account name 'Azuread\JohnSmith' and use this to query Entra via the Graph API.
I've searched the Entra Admin Centre, but cannot find an attribute which holds the AzureAD account name for any users in my test tenant.
Microsoft obviously do this mapping of AzureAD Account to Entra User entity internally, so I am hoping there is a way to do this.
I'd be grateful for any pointers or suggestions.
Thanks John
Share Improve this question asked Mar 21 at 12:59 JohnK88JohnK88 1 2 |1 Answer
Reset to default 0Note: Using Microsoft Graph API, you cannot directly call AzureAD\JohnSmith
- To map a local
AzureAD\JohnSmith
account to an Entra ID user, you can query Entra ID using the UserPrincipalName (UPN), in the format[email protected]
. Use the Microsoft Graph API to find the user by UPN:
var result = await graphClient.Users["{user-id}"].GetAsync();
If necessary, check the OnPremisesSamAccountName
for on-premises sync scenarios using Microsoft Graph API.
GET https://graph.microsoft/v1.0/users/[email protected]
Reference:
Get user - Microsoft Graph v1.0 | Microsoft Learn
AzureAD\JohnSmith
account to an Entra ID user, you can query Entra ID using the UserPrincipalName (UPN), typically in the format[email protected]
. Use the Microsoft Graph API to find the user by UPN:var user = await graphClient.Users["[email protected]"].GetAsync();
If necessary, check theOnPremisesSamAccountName
for on-premises sync scenarios. – Rukmini Commented Mar 24 at 7:31