如何将此WIF3.5代码转换为WIF4.5

本文关键字:代码 转换 WIF4 WIF3 | 更新日期: 2023-09-27 17:58:40

我有一个来自WIF 3.5的代码示例,但我还没有成功转换到WIF 4.5。

  1. 索赔收集在4.5中消失
  2. 系统之间存在歧义。IdentityModel。索赔。索赔和系统。安全索赔。宣称不确定哪一个等同于原始代码中的索赔
  3. 我一直在尝试ClaimsIdentity而不是ClaimsCollection,但ClaimsIdentity对象中的声明没有枚举器。这可能是一个明显的迹象,表明ClaimsIdentity不是在这里使用的合适类型,但我还没有找到合适的类型

这是代码:

ClaimCollection claims = ((IClaimsIdentity) HttpContext.Current.User.Identity).Claims;    
IEnumerable<Claim> claimQuery = from c in claims
     where
     c.Type ==
     "http://schemas.xmlsoap.org/ws/2005/05/identity/claims/upn"
select c;

如何将此WIF3.5代码转换为WIF4.5

var cp = HttpContext.Current.User as System.Security.Claims.ClaimsPrincipal;
IEnumerable<Claim> claims = cp.FindAll("http://schemas.xmlsoap.org/ws/2005/05/identity/claims/upn");