开发者

Multiple roles in ASP Menu

开发者 https://www.devze.com 2023-02-06 09:56 出处:网络
I have a problem with asp.net menu. I开发者_如何学JAVA have a parent menu with 3 childs. 2 of child have an anonymous access, and 1 child have a role base access. But the parent has access

I have a problem with asp.net menu. I开发者_如何学JAVA have a parent menu with 3 childs. 2 of child have an anonymous access, and 1 child have a role base access. But the parent has access e.g : PARENT - Child A - Child B - Child C

Child A & B have anonymous acces, or in role I can use "*" character. but Child C is just show to specific role, not anonymous.

How can I set role for PARENT ? Child A, B and C in asp.net menu (.net framework 4) I used sqlsitemapprovider.


You can set the PARENT role to "*" as well. As long as Child C has it's role specified, it will be filtered out accordingly.

So for your example do this:

PARENT roles="*"
  ChildA roles="*"
  ChildB roles="*"
  ChildC roles="RoleC"

If you had specific roles for each node then you would set the roles like this:

PARENT roles="RoleA,RoleB,RoleC"
  ChildA roles="RoleA"
  ChildB roles="RoleB"
  ChildC roles="RoleC"

To have these filtered based on these roles you will need to enable security trimming in your web.config. A guide can be found here: http://msdn.microsoft.com/en-us/library/ms178428.aspx

The security trimming is based on access rules you define (Guide here: http://msdn.microsoft.com/en-us/library/9ab2fxh0.aspx).

Explicitly setting the roles as is suggested above does not actually restrict the viewing of the linked pages or even the menu items themselves. It is done to avoid URL authorization calls (checking the access rules for each linked item) and therefore help with performance. So it's a good idea, but it is not the only thing that needs to be done.

0

精彩评论

暂无评论...
验证码 换一张
取 消