UserPrincipal.FindByIdentity returns null on IIS Server

v7web

New Member
I have following code sample in ASP.NET\[code\] 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; } } }\[/code\]The web.config looks like\[code\]<authentication mode="Windows" /><authorization> <deny users="?" /></authorization>\[/code\]I tried the code on my local development machine (part of domain, logon as domain user, VS2010, .Net 4.0, Windowx XP) to test locally, I am able to get \[code\]UserPrincipal\[/code\] object.If I deploy to WIndows 2003 (also part of the domain), IIS6, .Net 4.0 with application pool running under Network Service, I turned off anonymous access. But the code is not able to get \[code\]UserPrincipal\[/code\] object.Do I have to change application pool to run under a domain account in order to get \[code\]UserPrincipal\[/code\]?
 
Top