简体   繁体   English

如何从 Graph Explorer 查询另一个 Azure Active Directory 租户

[英]How to query another Azure Active Directory tenant from Graph Explorer

I am using Azure Graph API Explorer.我正在使用 Azure 图 API 资源管理器。 I want to query the apps list in a tenant.我想查询租户中的应用程序列表。 I am user in tenant_x (where user was originally created) as well as admin in tenant_y (created later with my user).我是 tenant_x 中的用户(最初创建用户的地方)以及 tenant_y 中的管理员(后来与我的用户一起创建)。 I understand that when I log in I go directly in the origin tenant (so tenant_x) therefore Graph Explorer does not allow me to query tenant_y.我知道当我 go 直接登录原始租户(所以 tenant_x)时,Graph Explorer 不允许我查询 tenant_y。 So as admin of tenant_y I have added a new user in tenant_y.因此,作为 tenant_y 的管理员,我在 tenant_y 中添加了一个新用户。 I log in now with that user but still I am not able to query the applications that are in tenant_y.我现在使用该用户登录,但仍然无法查询 tenant_y 中的应用程序。 So how can I query apps in tenant_y?那么如何查询tenant_y中的应用呢? Is there a way?有办法吗? thanks.谢谢。

The API I am calling (with new user log-in) to first retrieve all applications:我正在呼叫的 API(使用新用户登录)首先检索所有应用程序:

https://graph.microsoft.com/beta/applications

Response is:响应是:

{
"@odata.context": "https://graph.microsoft.com/beta/$metadata#applications",
"value": []
}

Of course I have apps in that tenant.当然,我在那个租户中有应用程序。

Based on our communication, you have used a personal account as guest of tenant_y to query the apps list in tenant_y.根据我们的沟通,您已使用个人帐户作为tenant_y 的guest 来查询tenant_y 中的应用程序列表。

Unfortunately, Microsoft Graph Explorer will not recognize your personal account as a guest user.遗憾的是,Microsoft Graph Explorer 不会将您的个人帐户识别为来宾用户。 It will still treat it as a personal account.它仍然会将其视为个人帐户。

So it will query the apps list for the personal account rather than tenant_y.因此它将查询个人帐户的应用程序列表而不是tenant_y。

So now you have two choices:所以现在你有两个选择:

  • Create a new user in tenant_y by following add a new user and then use this new user to log into Microsoft Graph Explorer to query the apps list.通过以下添加新用户在tenant_y 中创建新用户,然后使用此新用户登录Microsoft Graph Explorer 以查询应用列表。
  • Implement Get access on behalf of a user and make sure that you call {your tenant} endpoint rather than common endpoint while requesting the access token.代表用户实现获取访问权限,并确保在请求访问令牌时调用{your tenant}端点而不是common端点。 And you should use another tool (for example Postman ) instead of Microsoft Graph Explorer.并且您应该使用其他工具(例如Postman )而不是 Microsoft Graph Explorer。

Update:更新:

You can modify the permissions in Microsoft Graph Explorer like this:您可以像这样修改 Microsoft Graph Explorer 中的权限:

Click on the "modify permissions" under your username in Microsoft Graph Explorer and check the Directory.Read.All permission.在 Microsoft Graph Explorer 中单击您的用户名下的“修改权限”并检查Directory.Read.All权限。

在此处输入图片说明

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.请注意,在使用租户查询字符串转到此 URL 之前,您需要注销。 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).登录后,您可以对您有权访问的其他租户(不是您最初创建帐户的家庭租户)发出查询。

If you get a 401 while running the specific query, make sure you grant the required permissions on "Modify permissions" tab and click the Consent button in each required permission.如果您在运行特定查询时收到 401,请确保您在"Modify permissions"选项卡上授予所需权限,并单击每个所需权限中的Consent按钮。 After that your query should return a 200 success result.之后,您的查询应返回 200 成功结果。

在此处输入图像描述

Graph Explorer today does not support signing in to the tenanted endpoint. Graph Explorer目前不支持登录到租户端点。 A tenanted endpoint is used in the following format租户端点按以下格式使用

https://login.microsoftonline.com/ {tenantId}/V2.0 https://login.microsoftonline.com/ {tenantId}/V2.0

Once your user account from tenant_x is made a guest user in tenant_y, to effectively query tenant_y using your guest user account, an app (like Graph explorer) has to sign you in the other tenant.一旦您的tenant_x 用户帐户成为tenant_y 中的guest 用户,要使用您的guest 用户帐户有效地查询tenant_y,应用程序(如Graph explorer)必须让您登录另一个租户。 Instead Graph Explorer uses the /Common endpoint, which will always sign you in your home tenant (tenant_x).相反,Graph Explorer 使用/Common端点,该端点将始终在您的家庭租户 (tenant_x) 中登录。

The only available workaround is to develop a application quickly and sign-in to a tenant of your choice and run Apis in it.唯一可用的解决方法是快速开发应用程序并登录到您选择的租户并在其中运行 API。

Graph explorer is a tool to help developer's discover and learn about the Graph Api and thus might shy away from introducing too much complexity. Graph explorer 是一个帮助开发者发现和了解Graph Api 的工具,因此可以避免引入过多的复杂性。 But it does not hurt to ask for this feature at their Github repo .但是在他们的Github 存储库中要求此功能并没有什么坏处。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何将 Azure Active Directory 中的应用程序迁移到另一个租户 - How to migrate Applications in Azure Active Directory to another Tenant 将 Azure 活动目录设置克隆到另一个 AD(租户到租户迁移)? - Clone Azure active directory settings to another AD (tenant to tenant migration)? Azure Active Directory邀请管理器,在另一个租户中注册用户 - Azure Active Directory Invitation Manager, register user in another tenant Azure活动目录图API查询用户 - Azure active directory graph api query user 从 Azure Active Directory 创建的租户是否完全独立? - Is a tenant created from Azure Active Directory completely independent? 以编程方式从ID获取Azure Active Directory租户名称 - Programmatically obtaining Azure Active Directory tenant name from ID 如何获取与powershell中的azure中创建的活动目录关联的租户ID - how to get the tenant ID associated with an active directory created in the azure in powershell 如何在Azure Active Directory中创建Native Client Application单租户? - How to make Native Client Application single tenant in Azure Active Directory? 如何从 Azure 中的另一个租户访问一个租户中的资源? - How to access resources in one tenant from another tenant in Azure? 使用外部租户登录,Azure活动目录 - Login in with external tenant, Azure active directory
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM