The following code works fine from a variety of machines on our domain.
var context = new PrincipalContext(ContextType.Domain);
var principal = UserPrincipal.FindByIdentity(context, @"domain\username")
However, if I run this similar code on a machine that is not on a domain, it works but the FindByIdentity line takes 2+ seconds.
var context = new PrincipalContext(ContextType.Machine);
var principal = UserPrincipal.FindByIdentity(context, @"machinename\username")
Can this performance difference be addressed by supplying special parameters to the PrincipalContext constructor and/or the FindByIdentity method? Is there a setting in IIS or Windows that could be tweaked?
At the very least, can anybody tell me why it might be slower in the second scenario?
The code is running from an ASP.NET MVC 3 app hosted in IIS 7.5 (Integrated Pipeline) on Windows Server 2008 R2.