0
votes

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.

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

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.

1

1 Answers

2
votes

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.

Request: GET https://graph.microsoft.com/v1.0/organization

Response:

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"
    }
  ]
}