Get Help:Ask a Question in our Forums|Report a Bug|More Help Resources
Last post Nov 18, 2012 03:25 AM by BrockAllen
Nov 17, 2012 03:26 PM|LINK
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?
Nov 17, 2012 11:36 PM|LINK
Nov 18, 2012 12:19 AM|LINK
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
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.
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 :)
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.