Find out if customer has azure ad instance by email address

556 views Asked by At

Is there a way to find out if email address belongs to Azure Ad instance? I have a list of email addresses of my customers and I have to figure out if they have azure ad instance.

1

There are 1 answers

0
Rukmini On

I tried to reproduce the same in my environment and got the results like below:

To check if the User Emails belongs to the Azure AD Tenant, you can make use of PowerShell like below:

Connect-AzureAD
Get-AzureADUser -ObjectId [email protected]

If the User belongs to the connected Azure AD Tenant, then the user details will be retrieved otherwise it will throw an error like below:

enter image description here

You can also make use of the authorize endpoint to check if the user resides in the Azure AD Tenant.

For sample, when I use the below endpoint I get a sign-in screen.

https://login.microsoftonline.com/TenantID/oauth2/v2.0/authorize?
&client_id=ClientID
&response_type=code
&redirect_uri=https://jwt.ms
&response_mode=query
&scope=user.read
&state=12345

When I enter the user not belonging to the Azure AD Tenant, I get the below error:

enter image description here

If the User belongs to the Azure AD Tenant, then I get the redirect screen successfully like below:

enter image description here

enter image description here

Alternatively, you can also make use of Microsoft Graph API like below:

https://graph.microsoft.com/v1.0/users/[email protected]

enter image description here

For more in detail, refer below links:

Verify if user account exists in Azure Active Directory by Rohit Saigal

Check if an user is member of some Azure Active Directory Tenant by astaykov