I did something like this using only WindowsAuthentication. You can mark your actions with the Authorize attribute:
[Authorize(Roles = @"DashboardUsers")]
As long as this user is a member of the AD DashboardUsers group, they will have access to this action. It sounds like MVC magic, but it really is that simple.
Unfortunately, this approach will not allow you to overload the action for different roles, since the authorization attribute is not part of the method signature. In your views, you will need to show different anchor tags based on the current user role.
t
[Authorize(Roles = @"DashboardUsers\Manager")] public ActionResult IndexManagers() { .. }
or
[Authorize(Roles = @"DashboardUsers\Finance")] public ActionResult IndexFinance() { .. }
EDIT AFTER COMMENTS: Since your authentication comes from AD, you can use the logic in your controller, for example:
if(User.IsInRole("Finance")) { .. } else if(User.IsInRole("IT")) { .. }
And this will check which AD group they belong to. I know that this is not very elegant, but I cannot imagine how to mix Windows Auth with an individual identifier and manage permissions in your own db will be elegant too.
mambrow
source share