WindowsPrincipal principal = (WindowsPrincipal)Thread.CurrentPrincipal; // or, if you're in Asp.Net with windows authentication you can use: // WindowsPrincipal principal = (WindowsPrincipal)User; using (PrincipalContext pc = new PrincipalContext(ContextType.Domain)) { UserPrincipal up = UserPrincipal.FindByIdentity(pc, principal.Identity.Name); return up.DisplayName; // or return up.GivenName + " " + up.Surname; }
User.Identity.Name
if (User.Identity.IsAuthenticated) LabelUName.Text = User.Identity.Name; else LabelUName.Text = "No user identity available.";
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)