我正在构建一个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>
Run Code Online (Sandbox Code Playgroud)
当我使用用户授权时,它工作正常:
[Authorize(Users = @"DOMAIN\User1, DOMAIN\User2")]
public ActionResult Create()
{
return View();
}
Run Code Online (Sandbox Code Playgroud)
但是当我使用角色时,它只是不允许该组中的用户访问此操作:
[Authorize(Roles = @"Domain\Group")]
public ActionResult Create()
{
return View();
}
Run Code Online (Sandbox Code Playgroud)
我也试过指定组不带域正如我在其他阅读的答复,但没有运气......我想我错过了在Web.config的东西,但我不知道是什么...
我避免使用自定义角色提供程序,因为MVC4应该在没有自定义角色提供程序的情况下实现这一点(或者至少是我认为的那样)
谁能帮我这个?
提前致谢!