Sunday 15 February 2015

asp.net - Store/assign roles of authenticated users -


I am upgrading a site to use MVC and I am looking for the best way to set up authentication. .

At this point, I have to log in to Active Directory logging: Validating the username and password, and then setting up Auth cookie.

How do I store the user's role at the time of log -No, to see my controllers for those roles, as the user navigates through the site?

  [Author (roles = "admin")]  

I have no problem getting a list of roles from Active Directory I do not know That's where they keep them so that the controller can see them.

When you authenticate your user, you generate a new GenericPrincipal example. The constructor takes an array of strings that have roles for the user. Now set HttpContext.Current.User equal to the Genetic Principle and write auth cookie, and should do so.


No comments:

Post a Comment