首页 文章

如何使用其他租户的Azure AD应用程序?

提问于
浏览
0

我正在开发一个本机应用程序,必须显示用户所属的Office 365组 . 为此,我调用了需要身份验证的Microsoft Graph API . 我正在使用ADAL库 .

所需权限需要管理员同意 . 对于来自我的租户的用户来说,一切正常,但是当我尝试使用其他租户的帐户进行身份验证时,它无效 . 它不断给出这个结果:

相关ID:9780ed24-9d24-4604-b8bf-28a02c2ea580时间戳:2017-04-14 12:05:45Z AADSTS70001:在XXXXXXX.onmicrosoft目录中找不到标识符为“xxxxxxxx-xxx-xxx-xxxx-xxxxxxxxxxxx”的应用程序.COM

即使我在第一次连接时使用管理员帐户 . 我从未被要求获得同意,并且该应用程序未在其他租户上注册 .


该应用程序注册为Native,因此它应该是多租户,并且我将“/ common”作为权限中的租户传递 .

我还试图在另一个租户上注册一个具有相同规格的应用程序,给予管理员对权限的同意并且它也有效 .

以下是我检索访问令牌的方法:

private static string GetAccessToken()
    {
        AuthenticationContext authContext = new AuthenticationContext(authority);

        AuthenticationResult authResult = authContext.AcquireToken(graphResource, clientID, redirectURI, PromptBehavior.RefreshSession);
        var accessToken = authResult.AccessToken;
        return accessToken;
    }

这是代码中的问题吗?参数?其他租户是否需要一些'特殊的天蓝色订阅'我不知道?

简而言之: How do I get it to work for other tenants?

Edit :我尝试手动将"prompt=admin_consent"添加到请求中,如下所示:

AuthenticationResult authResult = authContext.AcquireToken(graphResource, clientID, redirectURI,PromptBehavior.RefreshSession, UserIdentifier.Any, "prompt=admin_consent");

但它触发了一个错误,说在extraQueryParameters中有一个“重复查询参数'提示'”

1 回答

  • 4

    注册本机客户端应用程序时,这是新Azure门户中的已知问题 .

    这些目前(截至2017-04-14)被创建为单租户应用程序 . 由于Azure门户不公开本机客户端应用程序的“多租户”切换,因此您需要更新应用程序清单或使用Azure AD PowerShell执行此操作 .

    Making an app multi-tenant from the manifest

    • 在Azure门户中,从本机客户端应用程序的设置刀片中,单击 Manifest 选项 .

    enter image description here

    • availableToOtherTenants 值更新为 true .

    enter image description here

    • 保存清单 .

    enter image description here

    Making an app multi-tenant with Azure AD PowerShell

    $appId = "<app ID>"
    $app = Get-AzureADApplication -Filter "appId eq '$appId'"
    Set-AzureADApplicatoin -ObjectId $app.ObjectId -AvailableToOtherTenants $true
    

    那应该修补它 . 稍等一下,然后再试一次 .

相关问题