skip to Main Content

We want to find the directory details in which user is a member. In Portal, these are found in Directories + Subscriptions tab.
How to get the same details using Azure API?
We found this API but getting only one organisation
GET https://graph.microsoft.com/v1.0/organization
Is there a way for all organization’s details in one API call? Thanks, Damodhar

2

Answers


  1. there isn’t a single API call that provides details for all organizations in a tenant.Microsoft Graph APi provides the organiztion endpoint, but it returns information about the organization to which the authenticated user belongs, so if you want information about the directories in which a user is a member, you might need to use the /me/memberOf endpoint to get the list of groups, directory roles, and administrative.

    GET https://graph.microsoft.com/v1.0/me/memberOf

    If you need more info on Microsoft graph API

    https://learn.microsoft.com/en-us/search/?terms=Microsoft%20Graph%20API%20&category=QnA

    Login or Signup to reply.
  2. Note that, you cannot get all the organizations details using Microsoft Graph API. Alternatively, you can use Azure Management API to fetch all the organizations associated to your account.

    I registered one Azure AD application and granted below API permission in it:

    enter image description here

    Now, I generated access token using username password flow via Postman with below parameters:

    POST https://login.microsoftonline.com/tenantId/oauth2/v2.0/token
    grant_type:password
    client_id: appId
    client_secret: secret 
    scope: https://management.azure.com/.default
    username: [email protected]
    password: xxxxxxxxx
    

    Response:

    enter image description here

    When I ran below Azure Management API call with generated token, I got list of organizations successfully as below:

    GET https://management.azure.com/tenants?api-version=2022-12-01
    

    Response:

    enter image description here

    Reference:
    Tenants – List – REST API (Azure Resource Management) | Microsoft

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search