1

I am using MVC 5 + Windows Authentication + Custom Roles, like this

protected void Application_PostAuthenticateRequest(object sender, EventArgs e)
    {
        List<string> roles = db.GetRoles(HttpContext.Current.User.Identity.Name);
        System.Security.Principal.GenericPrincipal ppl = new System.Security.Principal.GenericPrincipal(HttpContext.Current.User.Identity, roles.ToArray());
        HttpContext.Current.User = ppl;
    }

Everything works fine, means I can do

if (HttpContext.Current.User.IsInRole("SomeRole"))
    {
      //do my stuff
    }

My question is how to retrieve all the roles for the user? Remember I am not using RoleManager.

Eyedia
  • 31
  • 5

0 Answers0