【问题标题】:Microsoft Claims TenantId Removed, Changed or unavailableMicrosoft 声明 TenantId 已删除、更改或不可用
【发布时间】:2019-06-25 21:50:44
【问题描述】:

我有一个通过 OAuth 和 AzureAD 登录的网站。 我像这样获取我的 OAuth AuthenticationToken:

Claim tenantClaim = ClaimsPrincipal.Current.FindFirst(TenantIdClaimType);
if (tenantClaim != null)
{
    string tenantId = tenantClaim.Value;
    string userObjectID = ClaimsPrincipal.Current.FindFirst("http://schemas.microsoft.com/identity/claims/objectidentifier").Value;
    AuthenticationContext authContext = new AuthenticationContext(Startup.Authority, new NaiveSessionCache(userObjectID));
    ClientCredential credential = new ClientCredential(clientId, appKey);
    AuthenticationResult authenticationResult = await authContext.AcquireTokenSilentAsync(dynamicsUrl, credential, new UserIdentifier(userObjectID, UserIdentifierType.UniqueId));
    return authenticationResult.CreateAuthorizationHeader();
}

它一直运行良好。我失去了该网站大约 3 个月的跟踪,它不再工作了。我调试了我的代码并尝试“手动”进行。继续http://schemas.microsoft.com/identity/claims/tenantid,我看到了这条消息:

您要查找的资源已被删除,有它的名字 已更改,或暂时不可用。

它是被删除、重命名还是什么?我检查了 AzureAD,一切仍然有效(未过期)我什至创建了一个新的 appKey 并尝试了它,但它仍然无法正常工作。

我很抱歉我的英语不好我希望你们明白我在问什么,我在说什么。如果您需要更多信息,请告诉我。

感谢您抽出宝贵的时间,感谢您的帮助。

最好的问候, 尼科又名。万里达

【问题讨论】:

  • 那个 schemas.microsoft.com 是一个 URI,而不是一个 URL。这只是一个标识符:)
  • 您应该调试/记录用户可用的声明。

标签: oauth azure-active-directory claims


【解决方案1】:

我找到了解决办法。

这与声明无关,问题在于 NaiveSessionCache,因为 ADAL 更新了一个方法,以便它启动一个新线程..

在这里找到我的答案:HttpContext.Current is null on TokenCache.BeforeAccess

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-01-05
    • 2016-10-27
    • 2017-11-18
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多