【发布时间】:2019-02-13 02:17:15
【问题描述】:
如何从 GUID 获取 AAD 租户名称(不一定是我的)?理想情况下,这将通过 REST API,但 Azure CLI/Powershell 也可以。
我找到了答案here,但它需要转到 Azure 门户。
这里和其他地方也有很多关于从名称中获取租户 ID 的链接,但我的方向相反。
【问题讨论】:
标签: azure azure-active-directory
如何从 GUID 获取 AAD 租户名称(不一定是我的)?理想情况下,这将通过 REST API,但 Azure CLI/Powershell 也可以。
我找到了答案here,但它需要转到 Azure 门户。
这里和其他地方也有很多关于从名称中获取租户 ID 的链接,但我的方向相反。
【问题讨论】:
标签: azure azure-active-directory
您可以通过调用 MS Graph API 中的 /organization 端点获取已登录用户的租户名称(和一些其他详细信息):https://docs.microsoft.com/en-us/graph/api/organization-get?view=graph-rest-1.0。
请求:GET https://graph.microsoft.com/v1.0/organization
回复:
HTTP/1.1 200 OK
Content-type: application/json
Content-length: 411
{
"@odata.context": "https://graph.microsoft.com/v1.0/$metadata#organization",
"value": [
{
"assignedPlans": [
{
"assignedDateTime": "datetime-value",
"capabilityStatus": "capabilityStatus-value",
"service": "service-value",
"servicePlanId": "servicePlanId-value"
}
],
"businessPhones": [
"businessPhones-value"
],
"city": "city-value",
"country": "country-value",
"countryLetterCode": "countryLetterCode-value",
"displayName": "displayName-value"
}
]
}
【讨论】: