private void context_AuthenticateRequest(object sender, EventArgs e) { //HttpApplication app = (HttpApplication) sender; IPrincipal user = HttpContext.Current.User; if (user != null) { if (user.Identity.IsAuthenticated) { if (user.Identity.AuthenticationType == "Forms") { // try // { //We need the forms Identity so that we can get the userdata from the Forms Cookie FormsIdentity formID = (FormsIdentity)user.Identity; //Split the userdata into two strings, MemberID and Role Memberships string[] userInfo = formID.Ticket.UserData.Split(';'); //Create the new identity based on the form identity, including MemberID COPRIdentity iden = new COPRIdentity(formID, Convert.ToInt32(userInfo[0])); //Create a new Principal Object With Roles, and Role Levels HttpContext.Current.User = new COPRPrincipal(iden, userInfo[1].Split(',')); // } // catch (Exception) // { // FormsAuthentication.SignOut(); // // } } } } }
public COPRPrincipal(COPRIdentity Identity, string[] Perms) { _Identity = Identity; _SystemAreaPermissions = Perms; Array.Sort(_SystemAreaPermissions); }