views:

120

answers:

1

Hi Friends,

I am in need of best method to achieve role based authentication/authorization. The requirements are

  • It should check accessibility page level, based on role
  • It should be able to handle visibility of controls of page based on role
  • And that all can be managed using web.config or any XML file

I am familiar with asp.net native membership facility and as far as I know it can help to achieve authorization up to page level, I do not have idea if there is anything that can work control level.

Or I will have to place code User.IsInRole("Admin") everywhere on pages to show/hide controls?

Thanks,

Vipul

+2  A: 

Forms Authentication does exactly this. There are ASP.NET controls for showing and hiding content based on the current user principal.

I believe the control is called LoginView or something similar:

http://msdn.microsoft.com/en-us/library/ms178329.aspx

Adam
Yes. Take a look at asp:LoginView, it's not hard to bind controls and have Visible='<%# User.IsInRole("Admin")%>' where needed either.
Johan Kronberg
ok, gr8 I understand. What I thought was just to set things in resource or any XML file for controls to enable/disable based on specific roles. Thanks for help
Vipul Limbachiya