code_junkie

User configurable security in multi-tenant ASP.NET website

Nov 11th, 2011
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.42 KB | None | 0 0
  1. if (!user.InGroup("Admin")
  2. Response.Redirect("/NoAccess.aspx");
  3.  
  4. Table "Role"
  5. RoleId, TenantId, Role
  6.  
  7. Table "PagePermissions"
  8. PageId, RoleId
  9.  
  10. Table "UserRoles"
  11. UserId, RoleId
  12.  
  13. Select PageId FROM
  14. UserRoles UR INNER JOIN PagePermissions PP
  15. ON UR.RoleId = PP.RoleID
  16. WHERE UR.Userid = @UserId AND PP.PageID = @PageId
  17.  
  18. foreach(var group in ThisPageConfiguration.AcceptedRoleNames)
  19. if (user.IsInRole(group))
  20. ...
Add Comment
Please, Sign In to add comment