以编程方式从ID获取Azure Active Directory租户名称 [英] Programmatically obtaining Azure Active Directory tenant name from ID

查看:95
本文介绍了以编程方式从ID获取Azure Active Directory租户名称的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何从GUID获得AAD租户名称(不一定是我的)?理想情况下,这将通过REST API进行,但是Azure CLI/Powershell也可以工作.

How can I get an AAD tenant name (not necessarily mine), from a GUID? This would be via the REST API ideally, but the Azure CLI/Powershell works too.

我在此处找到了答案,但这需要转到Azure门户.

I found an answer here, but it requires going to the Azure Portal.

从名称中获取租户ID时,这里和其他地方也有很多链接,但我的方向相反.

There are also plenty of links here and elsewhere on obtaining the tenant ID from the name, but I'm going in the opposite direction.

推荐答案

您可以通过调用MS Graph API中的/organization端点来获取已登录用户的租户名称(以及其他一些详细信息): https://docs.microsoft.com/zh-我们/graph/api/organization-get?view=graph-rest-1.0 .

You can get the tenant name (and some other details) for the signed-in user by calling the /organization endpoint in MS Graph API: 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"
    }
  ]
}

这篇关于以编程方式从ID获取Azure Active Directory租户名称的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆