I have an MVC 3 intranet application that performs windows authentication against a particular domain. I would like to render the current user\'s name.
in the view,<
Another option, without requiring a helper... You could just declare context and principal before you need to utilize these values, and then utilize it like a standard output...
@{ // anywhere before needed in cshtml file or view
var context = new PrincipalContext(ContextType.Domain);
var principal = UserPrincipal.FindByIdentity(context, User.Identity.Name);
}
Then anywhere within the document, just call each variable as needed:
@principal.GivenName // first name
@principal.Surname // last name