I have an ASP.NET MVC app that uses Windows Integrated Authentication (an intranet app). This works great, and the user get's SSO into the application.
Currently, so I can get extra user information (user displayname, Guid, email etc) I am doing the following in my controllers:
private UserPrincipal currentUser = null;
private UserPrincipal CurrentUser
{
get
{
if(currentUser == null)
{
using (var context = new PrincipalContext(ContextType.Domain))
{
currentUser = UserPrincipal.FindByIdentity(context, User.Identity.Name);
}
}
return currentUser;
}
}
Is there a better way?
Thanks for any advice,
Richard
Go to the complete details ...