azure-active-directory - Get information about invitation of B2B user in Microsoft Graph
问题描述
I'm trying to create an application in which I need to know whether user invited to Azure Active Directory accepted an invitation or not. I'm using microsoft graph SDK for C# to get information about users from AAD but I cannot find information about invitation status in the resulting user object. In particular, I want to get this piece of information from Azure:
Is there any way to get this info from C# using Microsoft Graph SDK or with direct graph query?
解决方案
It seems microsoft graph api(v1.0) for get user doesn't have the field to show if the guest accept the inviatation. I checked the document of user properties and didn't find any property which matches "accept invitation". But I found there is a property externalUserState
in microsoft graph api(beta version) which can meet your requirements. If you don't mind the stability, you can use the beta version of microsoft graph api. If you will use this api in production environment, I suggest you to use Azure AD graph api. Please refer to the steps below:
As a workaround, we can use Azure AD graph api instead of microsoft graph api. I found there is a property UserState
in the response of Azure AD graph api. If we want to request this Azure AD graph api, we need to add the required permissions first.
Don't forget grant admin consent and then request the access token, please note that when request the access token for Azure AD graph, we need to change the scope
from https://graph.microsoft.com/.default
to https://graph.windows.net/.default
.
Then use the access token to request the Azure AD graph api.
https://graph.windows.net/<tenant id>/users/<object id>?api-version=1.6
Get the response of the api and we can find there is a property userState
in it. If the guest has accepted, this property will be "Accepted", if the guest hasn't accepted, this property will be "PendingAcceptance".
Hope it helps~
推荐阅读
- amazon-web-services - 为什么对 ECS 容器的所有请求都只发送到 AWS 中的 1 个(共 2 个)EC2 实例?
- python - 化简分数
- powershell - LocalUser 的 ChangePasswordAtLogon
- azure - 无法使用 AKS 访问外部负载均衡器
- python - (Blockchain.py) 浏览器(或代理)发送了一个服务器无法理解的请求
- c# - ASP.NET Core 3.0 MVC 更新模型与列表对象 - 添加对象
- python - python for循环以严格的顺序处理
- javascript - 设置节点之间的固定距离 d3-force
- reactjs - 为什么我的表格组件过滤器会使浏览器选项卡崩溃?
- android - Android Studio 4.1.1“系统 UI 没有响应”错误