Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

is there an authorizeattribute equivalent to just standard web forms (not MVC) for .net

I'm working on a project that will use windows role providers and I want to limit functionality to certain AD groups.

With MVC, I could use an AuthorizeAttribute above my action methods and redirect accordingly. Is there something similar I can do for a standard web forms application (.NET 3.5) that doesn't use MVC?

like image 271
Blair Jones Avatar asked Nov 18 '10 17:11

Blair Jones


People also ask

What is authentication and authorization in C#?

Authentication is knowing the identity of the user. For example, Alice logs in with her username and password, and the server uses the password to authenticate Alice. Authorization is deciding whether a user is allowed to perform an action. For example, Alice has permission to get a resource but not create a resource.

How do I create a custom authorization filter in Web API?

To implement a custom authorization filter, we need to create a class that derives either AuthorizeAttribute , AuthorizationFilterAttribute , or IAuthorizationFilter . AuthorizeAttribute : An action is authorized based on the current user and the user's roles.


Video Answer


1 Answers

You can set this up in web.config with the authorization element.

<configuration>
  <system.web>
    <authorization>
      <allow roles="domainname\Managers" />
      <deny users="*" />
    </authorization>
  </system.web>
</configuration>

Basically domain groups are translated into roles when using <authentication mode="Windows" />. You can read more about it on MSDN

like image 56
Klaus Byskov Pedersen Avatar answered Sep 19 '22 01:09

Klaus Byskov Pedersen