【问题标题】:Programmatically obtaining Azure Active Directory tenant name from ID以编程方式从 ID 获取 Azure Active Directory 租户名称
【发布时间】:2019-02-13 02:17:15
【问题描述】:

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

我找到了答案here,但它需要转到 Azure 门户。

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

【问题讨论】:

    标签: azure azure-active-directory


    【解决方案1】:

    您可以通过调用 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"
        }
      ]
    }
    

    【讨论】:

    • 谢谢。您知道是否可以对任意 ID 执行相同操作?即,不仅仅是登录用户的。
    • 据我所知没有。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2022-06-16
    • 2016-08-04
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多