5

I have two directories in a single login of Azure.

When I hit the Graph Explorer API to get the users, it automatically goes to the default AD.

https://graph.microsoft.com/v1.0/users

I want to switch the directory and then get the users.

I just found this documentation where an app needs to be registered and you provide directory name in the tenant.

Please help.

Marc LaFleur
  • 31,987
  • 4
  • 37
  • 63
Shallu
  • 127
  • 1
  • 5

2 Answers2

2

The document you found is for the registered app to communicate with Azure AD. It's not for Graph Explorer.

As I known, it's not possible to switch Directory in Graph Explorer. I test both Microsoft Graph and Azure AD Graph. I can only get users from the Default Directory.

My suggestion is that you can login Graph Explorer with another account which has another default directory.

You can also feedback Microsoft Graph in this UserVoice Forum.

Hope this helps!

Wayne Yang
  • 9,016
  • 2
  • 20
  • 40
  • Thanks Wayne, but I want to access this API from my application itself and there is an option to provide the tenant while fetching the token. Does that mean I can fetch users from a specific AD from the application? – Shallu Nov 02 '17 at 12:29
  • Correct. You can't supply your credentials from Tenant A to Tenant B, it wouldn't know what to do with them. A given tenant can only authenticate users _from_ that tenant. – Marc LaFleur Nov 02 '17 at 16:33
  • Hi, @Shallu . Sorry for my unclear reply. I think you cannot get users from a specific AD with the application. Because that the application use v2 endpoint to communicate with AD. But you still need to get users with Graph API use v1 endpoint. Although you can use the token which come from the application. See more details in this document:https://developer.microsoft.com/en-us/graph/docs/concepts/auth_v2_service Also thanks for Marc LaFleur 's comment. – Wayne Yang Nov 03 '17 at 01:33
  • It's a bit frustrating that you can't do this within the Graph Explorer provided from Microsoft. An alternative here is querying with a REST client like Postman or Insomnia. You can query at the separate directory in the same way an application might, and if you've written the application already, you should have a means for debugging and re-running queries. – Mike Wright Aug 31 '20 at 23:17
0

This information came from: https://stackoverflow.com/questions/60931681/how-to-query-another-azure-active-directory-tenant-from-graph-explorer

Today that's possible if you pass the tenant query string parameter like this:

https://developer.microsoft.com/en-us/graph/graph-explorer?tenant=mydomainname.onmicrosoft.com

Note that you need to logout before going to this URL with the tenant query string. It'll ask you to login again. After login you can issue queries against the other tenant you have access to (not your home tenant where your account was originally created on).

md5
  • 1
  • 1