Posted on: 7/9/2012 12:24:07 AM | Views : 257

We created a custom principal a while back to swap out the Windows security information NTID with an employee ID we read from a DB. The basic code was like this (name is the employee ID we pass in):
public class customPrincipal : IPrincipal { public customPrincipal(string name) { System.Security.Principal.GenericIdentity oUser = new System.Security.Principal.GenericIdentity(name); _Identity = oUser; } } We would load the information in the global.asax something like this (I left out the code where we get the employee ID string):
private void Application_AuthenticateRequest(object sender, System.EventArgs e) { //create new custom principal and update to user object customPrincipal cp = new customPrincipal(s_eid); HttpContext.Current.User = cp; //create auth cookie HttpCookie httpCook = new HttpCookie(sAppCookieName); ...

Go to the complete details ...