I'm automating Azure B2B Invitation process. At this stage I need to know if invited user has accepted invite or not.
Is there any way to do it?
There doesn't seem to be any programmatic way to do this at the moment as far as I can tell.
The attribute that tells you the the status is named source and can be read through the UI:
but is not included in the PowerShell cmdlet output for getting a user, nor in the Azure AD Graph API.
See this link for more information.
I recently needed some way of quickly determining the list of users who hadn't accepted these invitations. I realize the question is tagged with C#, but I ended up using PowerShell to accomplish this goal.
There exists a PowerShell module for AzureAD, which has a Cmdlet named Get-AzureADUser, that can give you the information you need.
Install the AzureAD PowerShell module by running the following command:
Install-Module AzureAD
After installation, you must import the module to make the Cmdlets available, and then authenticate:
Import-Module AzureAd
Connect-AzureAD
From here, it's a simple command to pull a list of all the users that haven't accepted the invitations:
Get-AzureADUser `
| Where-Object { $_.UserType -eq 'Guest' -and $_.UserState -eq 'PendingAcceptance' } `
| Select-Object -Property DisplayName,Mail,UserState,UserStateChangedOn `
| Sort-Object -Property DisplayName `
| Format-Table -AutoSize
To see a list of users who have accepted invitations, you can instead use $_.UserState -eq 'Accepted' within the Where-Object ScriptBlock.