How to get user groups from on-premise ADFS claims

最后都变了- 提交于 2019-12-12 09:20:54

问题


I have followed this article to build demo app with on-premise ADFS federation.

http://www.cloudidentity.com/blog/2014/02/12/use-the-on-premises-organizational-authentication-option-adfs-with-asp-net-in-visual-studio-2013/

I am able to get needed information for user using simple code

Dim UserEmail = System.Security.Claims.ClaimsPrincipal.Current.FindFirst(System.IdentityModel.Claims.ClaimTypes.Email).Value

But how I can get user groups where the username belongs and check if user account is member of Windows group in Active Directory?

I have tried to use System.Security.Claims.ClaimsPrincipal.Current.IsInRole to check if user is in group, but it won't work


回答1:


In ADFS claims rules, you need to configure a rule "Send LDAP Attributes as Claims" / "Token Groups - Unqualified Names" and map to "Role" as the "Outgoing Claim Type".

ADFS then provides all the security groups the user is memberOf in Role format and WIF maps them to the IsInRole construct.




回答2:


With this is enough.

ClaimsPrincipal.Current.AddIdentity(new ClaimsIdentity());
ViewBag.Name = ClaimsPrincipal.Current.FindFirst(ClaimTypes.Email).Value;

:)



来源:https://stackoverflow.com/questions/24610956/how-to-get-user-groups-from-on-premise-adfs-claims

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!