[英]ADFS get all roles for a Logged in user
i am using this sample application provided in http://technet.microsoft.com/en-us/library/cc753987%28WS.10%29.aspx to play around with ADFS claim aware application. 我正在使用http://technet.microsoft.com/zh-cn/library/cc753987%28WS.10%29.aspx中提供的示例应用程序来试用ADFS声明感知应用程序。 my question is how can i get all the roles that the user is in using ADFS, the code above only has an example to check for the roles using User.IsInRole(role). 我的问题是如何使用ADFS获得用户所具有的所有角色,上面的代码仅提供了一个使用User.IsInRole(role)检查角色的示例。
IClaimsPrincipal principal = (IClaimsPrincipal)this.Context.User;
IClaimsIdentity identity = principal.Identites[0];
var roles = identity.Claims
.Where( c => c.ClaimType == ClaimTypes.Role )
.Select( c => c.Value );
Refer How to: Access Claims in an ASP.NET Page 请参阅如何:在ASP.NET页中访问声明。
Edit : To answer the comment for WIF: 编辑 :要回答对WIF的评论:
For supported Operating Systems: Windows 7, Windows Server 2008 R2, Windows Server 2008 Service Pack 2, Windows Vista Service Pack 2 对于支持的操作系统:Windows 7,Windows Server 2008 R2,Windows Server 2008 Service Pack 2,Windows Vista Service Pack 2
For supported Operating Systems: Windows Server 2003 Service Pack 2 对于支持的操作系统:Windows Server 2003 Service Pack 2
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.