简体   繁体   English

拒绝访问特定角色

[英]Deny access to specific roles

I have a folder UserManagement with role based access and is as below. 我有一个具有基于角色访问权限的文件夹UserManagement,如下所示。

<authorization>
    <deny users="?" />
    <allow roles="UserAdmin_M"/>
    <allow roles="UserAdmin_MC"/>
    <deny roles="ReportsAdmin"/>
  </authorization>

Admin will have access to other folders as well like reports. 管理员将有权访问其他文件夹以及报告。 Now the problem is, I'm having an user "TestUser" with roles UserAdmin_M and ReportsAdmin but the application is blocking the access to "UserManagement" folder for TestUser. 现在的问题是,我有一个角色为UserAdmin_M和ReportsAdmin的用户“ TestUser”,但是该应用程序阻止了对TestUser的“ UserManagement”文件夹的访问。 How to overcome this? 如何克服呢?

I might be wrong, but could this have something to do with the order in which you have assigned the roles to your user? 我可能是错的,但这可能与您将角色分配给用户的顺序有关吗? From MSDN it states: 从MSDN,它指出:

At run time, the authorization module iterates through the allow and deny elements, starting at the most local configuration file, until the authorization module finds the first access rule that fits a particular user account . 在运行时,授权模块从最本地的配置文件开始遍历allow和deny元素,直到授权模块找到适合特定用户帐户的第一个访问规则 Then, the authorization module grants or denies access to a URL resource depending on whether the first access rule found is an allow or a deny rule. 然后,授权模块根据找到的第一个访问规则是允许还是拒绝规则来授予或拒绝对URL资源的访问。

Make sure you are assigning the UserAdmin_M role before the ReportsAdmin rule. 确保在ReportsAdmin规则之前分配了UserAdmin_M角色。

FYI - you can comma separate roles in your configuration: 仅供参考-您可以在配置中用逗号分隔各个角色:

<authorization>
    <deny users="?" />
    <allow roles="UserAdmin_M, UserAdmin_MC" />
    <deny roles="ReportsAdmin" />
</authorization>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM