Guest User
Guest User

Reputation: 9

Azure AD Graph API does not reliably tell me if a guest user already exists

Before I send a guest invite (or make other decisions), I need to know if the email address is already in use. Right now it appears the only option I have is to check by filtering the /users API by mail $filter=mail eq '[email protected]'

However, once an invite is sent, I noticed it takes sometimes more than 10 seconds to complete. So if I make another request beforehand, my code checking if(user.exists() returns false which causes unexpected behavior in code.. Because technically the user is there now. But the API doesn't immediately return the results that I need.

One of the possible solutions may be to convert the guest account's email to the UPN generated by Azure... I was looking into the suggestion referenced in Powershell - Checking if an Azure AD guest already exists

Is there a better solution? Is it reliable to change every @ symbol to _ and append #EXT# so that I can instead search the user by it's principal name (which I believe would give me the accurate answer right away) /users/{upn}

Upvotes: 1

Views: 492

Answers (1)

RahulKumarShaw
RahulKumarShaw

Reputation: 4602

The PowerShell script you are referring it is feasible solution you can use in your code.

if(user.exists() returns false which causes unexpected behavior in code.

Make sure the user is searching for, it is no longer available with it original email id in Azure AD because it has converted from $email = "[email protected]" to upn="john_gmail.com#EXT#tenant.onmicrosoft.com" when you invited.

So, Checking of your user existence is based on UPN not based on original email id.

You can use any concept of PowerShell Script provided in this SO to first replace @ to _ and append #EXT#@tenant.onmicrosoft.com. Then search based on UPN.

Upvotes: 2

Related Questions