0

I have a requirement in which I need to get a list of Azure AD B2B users who haven't accepted the invitation using csom or rest api

Can you please let me know whether graph provides any such endpoints?

Jason Pan
  • 15,263
  • 1
  • 14
  • 29
sj'
  • 43
  • 5

1 Answers1

0

According to my research, we can use Microsoft Graph User API to implement it. The user's property externalUserState represents the invited user's invitation status. For invited users, the state can be PendingAcceptance or Accepted, or null for all other users. But please note that if you want to use Microsoft Graph User API to get the property, we need to beta version enter image description here For example

  1. Get all users externalUserState
Get https://graph.microsoft.com/beta/users?$select=externalUserState,displayName,id
Authorization: Bearer <access_token>

enter image description here

  1. Get all users who haven't accepted the invitation
https://graph.microsoft.com/beta/users?$select=externalUserState,displayName,id&$filter=externalUserState eq 'PendingAcceptance'
Authorization: Bearer <access_token>

enter image description here

Jim Xu
  • 21,610
  • 2
  • 19
  • 39
  • Thanks Jim. It is helpful. But, the V1.0 of Microsoft Graph API does not provide these properties. I am not sure whether I can rely on this beta version as they can make changes at anytime. – sj' Mar 30 '20 at 22:28
  • @sj' According to the situation, you can try to use the AAD graph API `https://graph.windows.net/myorganization/users?$select=displayName,userState,userType&$filter= userType eq 'Guest'$api-version=1.6`:https://i.stack.imgur.com/fy9lA.png – Jim Xu Mar 31 '20 at 01:38
  • Thanks Jim. This is really helpful. I will try this from my end. – sj' Mar 31 '20 at 22:42
  • @sj' If it is useful for you, could you please accept it as an answer? It may help more people who have similar issue. – Jim Xu Apr 01 '20 at 01:07
  • Thanks Jim. It really helped me to resolve the issue.I had to make a small change to the endpoint "https://graph.microsoft.com/v1.0/myorganization/users" – sj' May 07 '20 at 00:45