I'm getting an exception within this code
var context = new PrincipalContext(ContextType.Domain, domainController, domainContainer, domainUser, domainPassword); ;
UserPrincipal user = UserPrincipal.FindByIdentity(context, User.Identity.Name);
System.ArgumentException occurred HResult=0x80070057 Message=The (&(objectCategory=user)(objectClass=user)(|(userPrincipalName=)(distinguishedName=)(name=))) search filter is invalid. Source=<Cannot evaluate the exception source> StackTrace: <Cannot evaluate the exception stack trace>
This is on my Windows 7 machine, joined to the domain. I'm passing in the correct credentials. It works OK on a 2008 R2 webserver. Is it something to do with my local IIS? I am trying to debug it within Visual Studio 2017.
Webconfig looks like below. I have tried with identity impersonate
true and false. Have also tried without validateIntegratedModeConfiguration
setting. I get the same exception regardless
<configuration>
<appSettings file="AppSettingsSecrets.config">
</appSettings>
<connectionStrings configSource="ConnectionStrings.config">
</connectionStrings>
<system.web>
<trust level="Full"/>
<compilation debug="true" targetFramework="4.0" />
<authentication mode="Windows"/>
<identity impersonate="false"/>
</system.web>
<system.web>
<customErrors mode="On" defaultRedirect="/error.htm"/>
</system.web>
<system.webServer>
<validation validateIntegratedModeConfiguration="false"/>
</system.webServer>
</configuration>
User contributions licensed under CC BY-SA 3.0