使用 ADFS 身份验证机制的站点地图控件创建基于角色的 ASP.NET 菜单
我目前正在使用 ADFS 身份验证机制来对用户进行身份验证。在这种情况下,我将身份验证模式设置为 None 而不是表单身份验证。用户成功登录后,声明对象将提供与登录用户关联的角色数据,因此在这种情况下,站点地图角色属性将如何从声明对象中获取角色。您能解释一下如何使用 securityTrimmingEnabled 属性吗?
我使用了自定义类 ADFSRoleProvider.cs,它继承了 RoleProvider 类并重写了方法 GetRolesForUser 方法,但除非我设置,否则不会调用该方法
<authentication mode="Forms"/>
,并且这反过来也无法与 siteMapNode 节点中提到的 Roles 属性进行交互。
主要问题是用户使用 ADFS 身份验证机制成功登录后,站点地图角色属性如何了解登录用户的角色。
请提供一些关于上述问题的代码示例和帮助。
I am currently using ADFS authentication mechanism to authenticate the user. In that case I am setting authenticationmode as None instead of forms authentication. After the user loggedIn successfully the claims object will provide the role data associated with the loggedIn user so in that case how the sitemap roles attribute will be able to pick up the role from the claims object. Can you explain me how the securityTrimmingEnabled property will be used.
I used the custom class ADFSRoleProvider.cs which inherits the RoleProvider class and overridden the method GetRolesForUser method but the method is not invoked unless I am setting the
<authentication mode="Forms"/>
and this in turn is also not able to interact with the roles attribute mentioned in the siteMapNode node.
The main issue is after the user logins in successfully using the ADFS authentication mechanism how will the sitemap role attribute know about the role of the loggedIn User.
Could please provide some code sample and help regarding the above mentioned issue.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您确定需要自定义角色提供程序吗?
IClaimsPrincipal
对象为用户提供角色,它采用ClaimTypes.Role
类型的声明。您的问题可能是由
securityTrimming
实现中的一些不一致引起的。几年前,我必须编写自己的站点地图提供程序才能正确处理修剪。只需在
web.config
中将其注册为您的 SiteMapProvider:Are you sure that a custom role provider is necessary? The
IClaimsPrincipal
object provides roles for the user, it takes your claims of typeClaimTypes.Role
.It could be that your issue is caused by some inconsistencies in the
securityTrimming
implementation. Years ago I had to write my own sitemap provider to correctly handle the trimming.Just register it in the
web.config
as your SiteMapProvider: