Posted on: 4/25/2013 5:16:49 PM | Views : 375

Here's my situation:
I have an MVC4 intranet applciation using Windows Authentication, with anonymous authentication enabled.  I have the landing page of my intranet set so anonymous users can see it, but I want to display the username of the people who are logged into a computer on the domain.  The thing is, even the user names of the users currently authenticated on the domain are not showing, until they hit a page that uses the [Authorize] attribute.
This is the ADHelper codeblock where I get the users full name:
public static string GetDN(IPrincipal u) { var dn = ""; using (var context = new PrincipalContext(ContextType.Domain)) { try { var principal = UserPrincipal.FindByIdentity(context, u.Identity.Name); dn = principal.GivenName + " " + ...

Go to the complete details ...