【发布时间】:2015-03-05 13:37:03
【问题描述】:
我在基于 WebForms 的应用程序中使用 Kentor HttpModule。 我需要获取使用登录声明的其他信息。我不确定,但我认为 Kentor 只解析 attributeID="userId",我需要获取更多属性。
我是否需要 fork 和修改 Kentor 才能在我的应用程序中使用这些值,或者它们存储在某个地方。
我在 Saml2Response 中看到从 AllAssertionElementNodes 方法返回的 xmlElements 集合,但我不知道如何在应用程序中访问它们。
要访问 ID,我正在使用此扩展方法:
public static string GetNameID(this IIdentity identity)
{
var claimsIndentity = identity as ClaimsIdentity;
if (string.IsNullOrWhiteSpace(claimsIndentity)
{
return string.Empty;
}
var providerQuery = from c in claimsIndentity.Claims
where c.Type.EndsWith("/identity/claims/nameidentifier")
select c.Value;
var provider = providerQuery.FirstOrDefault();
return provider;
}
还有这个:
if (User.Identity.IsAuthenticated)
{
userId = User.Identity.GetNameID();
}
有什么建议吗?
更新
我相信这是一个合适的解决方案。在 AcsCommand 的 ProcessResponse 方法中,我们有一个 samlResponse InnerXML,从那里我们可以解析想要的数据,创建额外的声明,或者其他什么,所以现在我有了一个解决方案(解决方法可能是我的问题)。还有其他更优雅的解决方案吗?
【问题讨论】:
标签: c# saml-2.0 claims-based-identity kentor-authservices