System.ArgumentException occurred - UserPrincipal.FindByIdentity

0

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>
c#
.net
ldap
asked on Stack Overflow Feb 5, 2018 by Syntax Error

0 Answers

Nobody has answered this question yet.


User contributions licensed under CC BY-SA 3.0