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 controller开发者_开发知识库s. 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?
You want to use the Roles property. Note that this can be a comma-separated list of roles.
[Authorize(Roles=@"domain\group")]
精彩评论