title: Trouble Authenticating ASP.NET Users Against Active Directory
body: <p>I replaced our domain name with &quot;demo&quot;... please ignore missing commas and such in the image below.</p>
  <p>My question is as follows:</p>
  <p>I want to authenticate the SBSUsers in my ASP.NET web application. I cannot figure out what my active directory path needs to be in order to get it to work...</p>
  <p>When I set it as follows, it fails to authenticate (I assume because my users are not under that path)... but it doesn't give me an error:</p>
  <pre><code>string adPath = &quot;LDAP://ac-dc01.demo.local:389/CN=Configuration,DC=demo,DC=local&quot;;
  string domainAndUsername = domain + @&quot;\&quot; + username;
  DirectoryEntry entry = new DirectoryEntry(adPath, domainAndUsername, pwd);
  // Bind to the native AdsObject to force authentication.
  Object obj = entry.NativeObject;
  DirectorySearcher search = new DirectorySearcher(entry);
  search.Filter = &quot;(SAMAccountName=&quot; + username + &quot;)&quot;;
  search.PropertiesToLoad.Add(&quot;cn&quot;);
  SearchResult result = search.FindOne();
  if (null == result)
  {
      return false;
  }
  // Update the new path to the user in the directory
  adPath = result.Path;
  _filterAttribute = (String)result.Properties[&quot;cn&quot;][0];
  </code></pre>
  <p>When I set it to what I think it should be, it errors on the entry.NativeObject line.</p>
  <pre><code>string adPath = &quot;ldap://ac-dc01.demo.local:389/OU=SBSUsers,OU=Users,OU=MyBusiness,DC=demo,DC=local&quot;;
  </code></pre>
  <p>Any ideas?  Do I need to open it up for &quot;global&quot; access somehow?  If so, how would I go about doing that?</p>
  <p><img src="https://i.stack.imgur.com/amOaa.png" alt="LDAP" /></p>
  <p>I was able to successfully connect using another piece of software...</p>
  <p><img src="https://i.stack.imgur.com/ivNiy.png" alt="LDAP" /></p>