Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Authorize an entire security group to perform an Action in ASP.Net MVC

I'd like to authorize users to perform specific actions within my controllers. I've found the ASP.NET tutorial which explains how to allow individual users to perform specific actions but can this be extended to security groups? For example, would everyone belonging to the "domain\group" security group have access to the GetSecrets action if the code looked like this:

[Authorize(Users="domain\group")]
public ActionResult GetSecrets()
{ return View(); }

If not, how would I do this?

like image 444
sdr Avatar asked Nov 19 '09 22:11

sdr


People also ask

How do I set an authorized role in MVC?

Create the following database data tables. Open Visual Studio 2015 or an editor of your choice and create a new project. Choose "web application" project and give an appropriate name to your project. Select "empty" template, check on the MVC box, and click OK.


1 Answers

You want to use the Roles property. Note that this can be a comma-separated list of roles.

 [Authorize(Roles=@"domain\group")]
like image 200
tvanfosson Avatar answered Sep 19 '22 04:09

tvanfosson