Skip to content

Instantly share code, notes, and snippets.

@gprasant
Created May 11, 2012 17:22
Show Gist options
  • Save gprasant/2661135 to your computer and use it in GitHub Desktop.
Save gprasant/2661135 to your computer and use it in GitHub Desktop.
Setting HttpContext.User to a custom Domain rather that System.Security.Identity.User
void WindowsAuthentication_OnAuthenticate(object sender, WindowsAuthenticationEventArgs e)
{
// Instantiate a user repository so as to get User information
IRepository<User> userRepository = new Repository<User>();
if (e.Identity != null && e.Identity.IsAuthenticated)
{
WindowsIdentity wi = e.Identity;
User user = userRepository.GetBy(u => u.Name == wi.Name).FirstOrDefault();
user.Identity = wi;
HttpContext.Current.User = user;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment