title: How do I assign a Role to an OpenId user for an ASP.NET MVC site?
body: <p>I'm using OpenId in my ASP.NET MVC application. Works great :) Once i have the user's OpenId Identifier (once they have authenticated and returned to my site), i load up the users data (to get display name, etc).</p>
  <p>From here, i also know their roles.</p>
  <p>I'm not sure how to assign the role to the current Forms.Identity.</p>
  <p>here's my code...</p>
  <pre><code>// Load User...
  var user = GetUsers().ByOpenIdIdentifier(&quot;blahblahblahbl....&quot;);
  
  // Here means we have a user AND all the roles, for that user.
  
  // Forms Authenticate and Redirect.
  FormsAuthentication.SetAuthCookie(user.DisplayName, true);
  return RedirectToAction(&quot;Index&quot;, &quot;Home&quot;);
  </code></pre>
  <p>How can i change this code so the authenticated user also has their roles assigned?</p>
  <h3>Update</h3>
  <p>I stumbled across <a href="http://schotime.net/blog/index.php/2009/02/17/custom-authorization-with-aspnet-mvc/" rel="nofollow noreferrer">this web post</a> about making a custom Authorize attribute. Notice how they are checking the logged in users role that exists in the session? Also, the roles are an enumeration :) This is pretty funky, if u ask me :) Nice and simple.</p>
  <p>Thoughts (compared to a full on blown RoleProvider class?)</p>