title: Should i user windows roles in session?
body: <p>this might be very silly question but was wondering is there any advantage to store user windows roles in session. Basically in our mvc project before we render the view we check  if user has access to see the views based on user roles. I am looking at security point of view for storing them in session vs performance</p>
  
  <pre><code>   public class WindowsRoleProvider : IRoleProvider
     {
         public List&lt;string&gt; GetWindowsRolesForUser(string userName)
         {
            var windowsProvider = new WindowsTokenRoleProvider();
            var adsRoles = windowsProvider.GetRolesForUser(userName);
            return new List&lt;string&gt;(adsRoles);
         }
      }
      public  List&lt;string&gt; GetUserRoles(string userName)
      {
          var userRoles = new List&lt;string&gt;();
  
          try
          {
              var windowsRoles = _roleProvider.GetWindowsRolesForUser(userName);
              adsRoles = windowsRoles.ConvertAll(d =&gt; d.ToLowerInvariant());
              var catAuthorizationRoles = _configurationManager.GetSection("catroles");
              if (catAuthorizationRoles != null)
              {
                  for (var role = 0; role &lt; catAuthorizationRoles.Count; role++)
                  {
                      if (windowsRoles.Any(item =&gt;catAuthorizationRoles[role].ToLower().ToLower().Split(';').Any(s =&gt; item.Trim().Equals(s.Trim()))))
                      {
                          userRoles.Add(catAuthorizationRoles.GetKey(role));
                      }
                  }
              }
              userRoles = userRoles.ConvertAll(d =&gt; d.ToLower());
          }
          catch (Exception ex)
          {
              Logger.Error("Exception:" + ex.Message + "\r\nInner Exception:" +
                           (ex.InnerException != null ? ex.InnerException.Message : string.Empty) + "\r\n" +
                           ex.StackTrace);
          }
  
          return userRoles;
      }
  </code></pre>