You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

使用Microsoft Azure Graph API通过tenantId或用户ID GUID反向查询用户及外部域名

Microsoft Graph API 反向查询操作方案

1. 通过User ID GUID查询对应用户

调用标准用户查询接口即可,请求规则如下:

  • 请求方法:GET
  • 接口地址:https://graph.microsoft.com/v1.0/users/{替换为你的User ID}
  • 所需权限:至少拥有User.Read.All或Directory.Read.All权限(委托权限/应用权限均可)
  • 返回内容:包含用户完整属性集,包括邮箱、用户类型、所属组织等信息,可匹配你已拿到的用户ID对应数据。

2. 通过Tenant ID查询外部主体域名

调用租户信息查询接口即可获取目标租户的公开域名信息,请求规则如下:

  • 请求方法:GET
  • 接口地址:https://graph.microsoft.com/v1.0/tenantRelationships/findTenantInformationByTenantId(tenantId='{替换为你的Tenant ID}')
  • 所需权限:仅需基础Graph访问权限,无需目标租户额外授权
  • 返回字段说明:返回结果中的defaultDomainName即为该外部主体的默认域名,同时可获取租户显示名等公开信息。

你已拿到的返回数据结构参考如下:

"user": {
    "id": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxd0d8",
    "displayName": "External user",
    "tenantId": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxd0d8"
}

常见异常排查

  • 若查询用户返回404:确认User ID拼写无误,且该用户未被从当前租户目录中移除/软删除
  • 若查询租户返回403:确认调用身份已被分配正确的接口访问权限

内容的提问来源于stack exchange,提问作者Matthew Ringsell

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.10.21 07:36:07