I am looking to add custom roles to my MVC application which is Windows authentication enabled.
I'm basically looking to do something like decorate my Controller/Actions with an [Authorize] attribute, and specify custom roles in the Roles property for that attribute. Is this possible with Windows Authentication?
I'm not entirely sure I understand the contents of your blog post. It seems to be what I'm looking for but there's not enough information for someone who is new to pick it up without much context.
If you handle PostAuthRequest in global.asax then you can populate the current User object with whatever roles you need from whatever data store you want. I wish I had a MSDN article for you but they're all polluted with the role rovider crap.
mariocatch
Member
18 Points
44 Posts
Windows Authentication + Roles?
Nov 17, 2012 03:26 PM|LINK
Hello,
I am looking to add custom roles to my MVC application which is Windows authentication enabled.
I'm basically looking to do something like decorate my Controller/Actions with an [Authorize] attribute, and specify custom roles in the Roles property for that attribute. Is this possible with Windows Authentication?
BrockAllen
All-Star
28114 Points
4997 Posts
MVP
Re: Windows Authentication + Roles?
Nov 17, 2012 11:36 PM|LINK
http://brockallen.com/2012/05/23/think-twice-about-using-roleprovider/
DevelopMentor | http://www.develop.com
thinktecture | http://www.thinktecture.com/
mariocatch
Member
18 Points
44 Posts
Re: Windows Authentication + Roles?
Nov 18, 2012 12:19 AM|LINK
Thanks,
I'm not entirely sure I understand the contents of your blog post. It seems to be what I'm looking for but there's not enough information for someone who is new to pick it up without much context.
Basically, here's what I'm looking for:
- Windows authentication enbabled (done)
- Store custom roles in my database
- Authorize my Actions with custom role strings
BrockAllen
All-Star
28114 Points
4997 Posts
MVP
Re: Windows Authentication + Roles?
Nov 18, 2012 12:33 AM|LINK
If you handle PostAuthRequest in global.asax then you can populate the current User object with whatever roles you need from whatever data store you want. I wish I had a MSDN article for you but they're all polluted with the role rovider crap.
DevelopMentor | http://www.develop.com
thinktecture | http://www.thinktecture.com/
mariocatch
Member
18 Points
44 Posts
Re: Windows Authentication + Roles?
Nov 18, 2012 12:56 AM|LINK
So the body of your Application_PostAuthenticateRequest is all user logic? None of that is framework code (sans the context)?
Sounds easy enough :)
BrockAllen
All-Star
28114 Points
4997 Posts
MVP
Re: Windows Authentication + Roles?
Nov 18, 2012 03:25 AM|LINK
Yep -- that's all code you'd put in global.asax and then you basically implement LookupRolesForUser -- take username and return string[] of roles.
DevelopMentor | http://www.develop.com
thinktecture | http://www.thinktecture.com/