c# - Asp.Net Conditional URL Role Authentication -
I want to restrict access to a specific url unless the user is a member of 2 different roles. In this situation, I want to provide access to this URL only if the user is reporting both the reporting and role in ASP.NET, what is the way to do this?
& lt; Location path = "testpage.aspx" & gt; & Lt; System.web & gt; & Lt; Authority & gt; & Lt; Allow roles = "Reporting, Archived" / & gt; & Lt; Deny users = "*" /> & Lt; / Authorization & gt; & Lt; /system.web>
I want something like this:
& lt; Location path = "testpage.aspx" & gt; & Lt; System.web & gt; & Lt; Authority & gt; & Lt; Allow roles = "Reporting and archiving" /> & Lt; Deny users = "*" /> & Lt; / Authorization & gt; & Lt; /system.web>
It's ugly, but you can get it from You are currently using the role provider (SqlRoleProvider, WindowsTokenRoleProvider, AuthorizationStoreRoleProvider), override GetRolesForUser, call the base implementation to get the roles, and combine them according to the requirements, then it is obvious that your web.config In your custom role provider & lt; RoleManager & gt; Configuration section
You only need to override one method (and perhaps GetUsersInRole) and must combine them as necessary.
public override string [] GetRolesForUser (string user name) {list & lt; String & gt; Roles = New list & lt; String & gt; (Base.GetRolesForUser (username)); If there are roles ("reporting") and roles included ("archive")) (roles.ad ("reporting endearting"); } Return roles .Oir (); }
Comments
Post a Comment