问题描述
我在ASP.net MVC 3应用程序中使用Windows身份验证.我在系统中有几个不同的角色:
I'm using windows authentication in my ASP.net MVC 3 application. I have a few different roles in my system:
Administrator
PowerUser
GeneralUser
我们有一个规则,即每个环境中的AD组名称都不同.
We have a rule in place that the AD group names are different in each environment.
例如,在开发中,角色名称将为:
For example, in Development the role names will be:
Administrator_Dev
PowerUser_Dev
GeneralUser_Dev
在生产中只是:
Administrator
PowerUser
GeneralUser
在需要部署到其他环境中时,在不更改代码的情况下在这些不同的环境中使用Authorize是否有一个好的解决方案?
Is there a good solution for using Authorize in these different environments without changing the code when I need to deploy to a different environment?
推荐答案
您不能只实现所有角色吗?除非有一个Administrator_Dev角色成为生产站点的机会,否则...
Can't you just implement all of the roles? Unless there's a chance of an Administrator_Dev role being the production site...
[Authorize(Roles = "Administrator_Dev, Administrator")]
这篇关于ASP.net MVC-在具有Windows身份验证的多个环境中使用AuthorizeAttribute的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!