Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- protected void Application_PostAuthenticateRequest(Object sender, EventArgs e)
- {
- if (FormsAuthentication.CookiesSupported == true)
- {
- if (Request.Cookies[FormsAuthentication.FormsCookieName] != null)
- {
- try
- {
- string username = FormsAuthentication.Decrypt(Request.Cookies[FormsAuthentication.FormsCookieName].Value).Name;
- string roles = String.Empty;
- if (admins.Contains(username.ToLower()))
- roles += "admin;";
- if (publishers.Contains(username.ToLower()))
- roles += "publisher;";
- HttpContext.Current.User = new System.Security.Principal.GenericPrincipal(
- new System.Security.Principal.GenericIdentity(username, "Forms"), roles.Split(';'));
- }
- catch (Exception)
- {
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement