Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You need to implement a custom <a href="http://msdn.microsoft.com/en-us/library/system.security.principal.iprincipal.aspx" rel="nofollow noreferrer">IPrincipal</a> (or a custom <a href="http://msdn.microsoft.com/en-us/library/system.web.security.roleprovider.aspx" rel="nofollow noreferrer">RoleProvider</a>, but in my view IPrincipal is easier).</p> <p>In your forms authentication controller, authenticate against your user table and create an IPrincipal with roles from your role table. You will probably also want to set a Forms Auth cookie while you're at it with your roles so you don't need to hit the database each request (or use a session). Have a look at the code in <a href="https://stackoverflow.com/questions/3945907/custom-iidentity-and-iprincipal-using-formsauthenticationticket-cookie-in-mvc2">this question</a> for an example of this approach.</p> <p>If you don't have any custom attributes on your users, you may be able to use the built-in GenericIdentity and GenericPrincipal.</p> <p><strong>Edit</strong> - if you're storing your user information in the session, you'll just need to make sure you set HttpContext.Current.User to your session-derived IPrincipal at the start of each request (OnPostAuthenticate)</p> <p>You will need to rebuild/redeploy to cater for new roles with this approach. If you want to dynamically assign roles and handle them at runtime, you'd need to implement a custom AuthorizationAttribute - this could take (e.g.) a string 'Operation' parameter which can be matched to roles in the DB. I would personally leave this until it becomes obvious you need it. </p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload