I have the following code example in ASP.NET
using (PrincipalContext domainContext = new PrincipalContext(ContextType.Domain)) { using (UserPrincipal user = UserPrincipal.FindByIdentity(domainContext, HttpContext.Current.User.Identity.Name)) { if (user == null) { lbName.Text = "No User Principal"; } else { lbName.Text = user.DisplayName; } } }
Web.config looks like
<authentication mode="Windows" /> <authorization> <deny users="?" /> </authorization>
I tried the code on my local development machine (part of the domain, log in as a domain user, VS2010, .Net 4.0, Windowx XP) to check locally, I can get a UserPrincipal object.
If I upgrade to WIndows 2003 (also part of the domain), IIS6, .Net 4.0 with the application pool running in the Network Service, I disabled anonymous access. But the code cannot get the UserPrincipal object.
Do I need to change the application pool to run under a domain account in order to get a UserPrincipal ?
source share