SOLVED

Find all users in my tenant who are invited as guest in another tenant

%3CLINGO-SUB%20id%3D%22lingo-sub-2390436%22%20slang%3D%22en-US%22%3EFind%20all%20users%20in%20my%20tenant%20who%20are%20invited%20as%20guest%20in%20another%20tenant%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2390436%22%20slang%3D%22en-US%22%3E%3CP%3EHello%2C%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3Eas%20the%20discussion%20subject%20states%2C%20I%20would%20like%20to%20know%2C%20which%20users%20in%20my%20own%20tenant%20are%20invited%20in%20other%20tenants%20as%20guest%20user%20(e.g.%20invited%20in%20other%20tenants'%20teams).%3C%2FP%3E%3CP%3EIs%20there%20any%20option%2C%20to%20find%20that%20out%3F%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThe%20background%20is%2C%20that%20we%20need%20to%20find%20that%20out%20in%20a%20shadow%20(unmanaged)%20tenant%2C%20before%20deleting%20that%20tenant%20and%20starting%20with%20a%20new%20managed%20tenant.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3Ebest%20regards%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-2390436%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EAzure%20AD%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EGuest%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3Einvite%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2394508%22%20slang%3D%22en-US%22%3ERe%3A%20Find%20all%20users%20in%20my%20tenant%20who%20are%20invited%20as%20guest%20in%20another%20tenant%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2394508%22%20slang%3D%22en-US%22%3EHello%20%40GottfriedJocham%2C%20I%20am%20looking%20into%20this%20and%20let%20me%20get%20back%20to%20you%20on%20this.%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2395633%22%20slang%3D%22en-US%22%3ERe%3A%20Find%20all%20users%20in%20my%20tenant%20who%20are%20invited%20as%20guest%20in%20another%20tenant%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2395633%22%20slang%3D%22en-US%22%3E%3CP%3EHello%20%40GottfriedJocham%2C%20I%20did%20some%20lookup%20and%20it%20looks%20like%20what%20you%20can%20do%20here%20is%20call%20the%20following%20REST%20API%20%22%3CA%20href%3D%22https%3A%2F%2Fmanagement.azure.com%2Ftenants%3Fapi-version%3D2020-01-01%22%20target%3D%22_blank%22%20rel%3D%22noopener%20nofollow%20noreferrer%22%3Ehttps%3A%2F%2Fmanagement.azure.com%2Ftenants%3Fapi-version%3D2020-01-01%3C%2FA%3E%22%20and%20get%20list%20of%20the%20tenants%20that%20a%20user%20is%20a%20part%20of%20(in%20other%20words%2C%20where%20the%20user%20is%20added%20as%20guest%20user).%20One%20thing%20to%20note%20here%20is%20that%20this%20API%20requires%20a%20delegated%20permission%20(user%20permission)%20and%20how%20it%20works%20is%2C%20it%20would%20only%20shows%20the%20tenants%20of%20the%20user%20who%20has%20currently%20logged%20in%20and%20called%20this%20API%20with%20an%20access-token%20that%20was%20issued%20on%20behalf%20of%20that%20user.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EFor%20eg%3A%20If%20User-A%20logs%20in%20to%20your%20app%20that%20calls%20this%20API%2C%20then%20after%20user-A%20logs%20in%20and%20then%20AAD%20issues%20an%20access-token%20to%20the%20app%20on%20behalf-of%20User-A.%20When%20the%20app%20uses%20that%20access-token%20and%20calls%20the%20api%20%E2%80%9C%3CSPAN%3E%3CA%20href%3D%22https%3A%2F%2Fmanagement.azure.com%2Ftenants%3Fapi-version%3D2020-01-01%22%20target%3D%22_blank%22%20rel%3D%22nofollow%20noopener%20noreferrer%22%3Ehttps%3A%2F%2Fmanagement.azure.com%2Ftenants%3Fapi-version%3D2020-01-01%3C%2FA%3E%3C%2FSPAN%3E%E2%80%9D%2C%20then%20all%20the%20tenants%20that%20User-A%20is%20part%20of%20(added%20as%20guest%20user)%20would%20get%20listed.%3C%2FP%3E%0A%3CP%3E%3CBR%20%2F%3ETo%20read%20more%20on%20this%20API%2C%20please%20refer%3A%20%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Frest%2Fapi%2Fresources%2Ftenants%2Flist%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3Ehttps%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Frest%2Fapi%2Fresources%2Ftenants%2Flist%3C%2FA%3E%3C%2FP%3E%3C%2FLINGO-BODY%3E
Occasional Contributor

Hello,

 

as the discussion subject states, I would like to know, which users in my own tenant are invited in other tenants as guest user (e.g. invited in other tenants' teams).

Is there any option, to find that out?

 

The background is, that we need to find that out in a shadow (unmanaged) tenant, before deleting that tenant and starting with a new managed tenant.

 

best regards

4 Replies
Hello @GottfriedJocham, I am looking into this and let me get back to you on this.
best response confirmed by Gottfried Jocham (Occasional Contributor)
Solution

Hello @GottfriedJocham, I did some lookup and it looks like what you can do here is call the following REST API "https://management.azure.com/tenants?api-version=2020-01-01" and get list of the tenants that a user is a part of (in other words, where the user is added as guest user). One thing to note here is that this API requires a delegated permission (user permission) and how it works is, it would only shows the tenants of the user who has currently logged in and called this API with an access-token that was issued on behalf of that user.

 

For eg: If User-A logs in to your app that calls this API, then after user-A logs in and then AAD issues an access-token to the app on behalf-of User-A. When the app uses that access-token and calls the api “https://management.azure.com/tenants?api-version=2020-01-01”, then all the tenants that User-A is part of (added as guest user) would get listed.


To read more on this API, please refer: https://docs.microsoft.com/en-us/rest/api/resources/tenants/list

Thank you @souravmishra-msft!
In other words, I need to develop an app that calls that API with the user's delegated permission or am I wrong?
This requires each user to once call my app or did I missunderstood something here?

 

best regards

Gottfried

@GottfriedJocham, you are absolutely correct.