Getting all B2B directory users is a member

Since we have the Azure AD B2B feature in GA, I'm curious about how to use B2B in multi-tenant apps. Specifically, how do I get a list of directories that a user is a member of? For example, the Azure Portal does this by calling https://portal.azure.com/AzureHubs/api/tenants/List

Microsoft My Apps calling https://account.activedirectory.windowsazure.com/responsive/multidirectoryinfo

for information - is there a public endpoint for that?

The use case is to provide B2B interoperability between a multi-user application that is exposed in each user directory, so they have their own instances, but no way to centrally fetch information about user directories.

A simple workaround would be to query all tenants that have an app provided for the UPN user and if found, display it in the list, but imagine if there are hundreds of tenants ... I believe this is very important for app developers who want to leverage B2B functionality in multi-tenant applications.

Update: It looks like there is a way to do this by accessing the Azure Service Management API , however this API and method is undocumented and I suppose if there are any issues Microsoft will say this is not a supported scenario.

Update 2: I wrote an article on the whole setup including a sample project on how to use this in a script, it can be found here https://hajekj.net/2017/07/24/creating-a-multi-tenant-application- which-supports-b2b-users /

+3


source to share


1 answer


There is a publicly registered Azure Management API that allows you to do this: https://docs.microsoft.com/en-us/rest/api/resources/tenants

GET https://management.azure.com/tenants?api-version=2016-06-01 HTTP/1.1
Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJSUz...
...

      

The response body looks like this:



{
    "value" : [{
            "id" : "/tenants/d765d508-7139-4851-b9c5-74d6dbb1edf0",
            "tenantId" : "d765d508-7139-4851-b9c5-74d6dbb1edf0"
        }, {
            "id" : "/tenants/845415f3-7a05-45c2-8376-ee67080661e2",
            "tenantId" : "845415f3-7a05-45c2-8376-ee67080661e2"
        }, {
            "id" : "/tenants/97bcb93f-8dee-48ed-afa3-356ba40f3a61",
            "tenantId" : "97bcb93f-8dee-48ed-afa3-356ba40f3a61"
        }
    ]
}

      

The resource for which you need to get an access token https://management.azure.com/

(with a trailing slash!).

+1


source







All Articles