我正在为企业内部使用构建一个MVC4应用程序。我使用Windows认证,这很好运行,但是在使用Active Directory组作为授权角色方面遇到了麻烦。
我的Web.config文件如下:
<authentication mode="Windows" />
<roleManager enabled="true" defaultProvider="AspNetWindowsTokenRoleProvider">
<providers>
<clear />
<add name="AspNetWindowsTokenRoleProvider" type="System.Web.Security.WindowsTokenRoleProvider" applicationName="/" />
</providers>
</roleManager>
<authorization>
<deny users="?" />
</authorization>
当我使用用户授权时,它运行良好:
[Authorize(Users = @"DOMAIN\User1, DOMAIN\User2")]
public ActionResult Create()
{
return View();
}
但是当我使用角色时,它不允许属于该组的用户访问此操作:
[Authorize(Roles = @"Domain\Group")]
public ActionResult Create()
{
return View();
}
我也尝试了在其他回复中提到的不带域名指定组,但没有成功...我想我在Web.config中漏掉了什么,但我不确定是什么...
我一直避免使用自定义角色提供程序,因为MVC4应该可以在没有自定义角色提供程序的情况下实现这一点(至少我是这么认为的)
有人能帮我吗?
先感谢您!