开发者

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

开发者 https://www.devze.com 2022-12-12 14:00 出处:网络
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 action

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")]
0

精彩评论

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

关注公众号