2
我已經看到,AuthoriseAttribute可以爲每個單獨的控制器工作,我想要做的是將整個站點權限設置爲一個AD組,這很容易做到或者我應該複製並粘貼authattrib行到每個控制器?MVC Windows身份驗證 - 整個站點的授權(權限)
感謝
我已經看到,AuthoriseAttribute可以爲每個單獨的控制器工作,我想要做的是將整個站點權限設置爲一個AD組,這很容易做到或者我應該複製並粘貼authattrib行到每個控制器?MVC Windows身份驗證 - 整個站點的授權(權限)
感謝
由於@asawyer提到的使用全局過濾器爲您的情況是很好的做法。在評論你的問題的另一部分:in the global filter where do i specify what AD groups are allowed to use the site?
您可以在您的自定義授權屬性OnAuthorization
方法指定的角色,像水木清華:
public class MyAuthAttribute: AuthorizeAttribute
{
public override void OnAuthorization(AuthorizationContext filterContext)
{
Roles = 'ad role1, ad role2...'; //Roles is AuthorizeAttribute member
base.OnAuthorization(filterContext);
}
}
,比使用它像:
GlobalFilterCollection.Add(new MyAuthAttribute());
在Global.asax中
或w/e其他
添加一個全球過濾器就像在這個問題中演示的人:http://stackoverflow.com/questions/11033357/asp-net-mvc-global-authorize-filter-forcing-login-on-在全局過濾器w中的允許匿名動作 – asawyer
我在這裏指定哪些AD組可以使用該網站? – AlexW
也許這篇文章會很有用:http://blogs.msdn.com/b/rickandy/archive/2011/05/02/securing-your-asp-net-mvc-3-application.aspx –