private static void PostAuthenticateRequest(object sender, EventArgs e) { // Get a reference to the current user IPrincipal principal = HttpContext.Current.User; // Check if we are dealing with an authenticated forms authentication request if (principal.Identity.IsAuthenticated && principal.Identity.AuthenticationType == "Forms") { FormsIdentity formsIdentity = principal.Identity as FormsIdentity; if (formsIdentity == null) { return; // gaurd } // Create StudentIdentity based on the FormsAuthenticationTicket TDSIdentity identity = new TDSIdentity(formsIdentity.Ticket); // Create StudentPrincipal and get roles from FormsAuthenticationTicket TDSPrincipal tdsPrincipal = new TDSPrincipal(identity, formsIdentity.Ticket); // Attach the TDSPrincipal to HttpContext.User and Thread.CurrentPrincipal HttpContext.Current.User = tdsPrincipal; Thread.CurrentPrincipal = tdsPrincipal; } }
public TDSPrincipal(TDSIdentity identity, string[] testeeRoles) { this.tdsIdentity = identity; this.testeeRoles = testeeRoles; }
public TDSPrincipal(TDSIdentity tdsIdentity, FormsAuthenticationTicket ticket) { this.tdsIdentity = tdsIdentity; }