Created
May 11, 2012 17:22
-
-
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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