title: Why AdsObject is being binded to a native object in asp.net?
body: <p>I was working with an asp.net web application. I used form authentication to validate users from active directory. Everything works fine. But, I got confused why I should bind AdsObject to a native object which is never being used. My codes goes like this</p>
  
  <pre><code> DirectoryEntry entry = new DirectoryEntry(_path, domainAndUsername, pwd);
          string[] uName;
          try
          {
              //Bind to the native AdsObject to force authentication.
              object obj = entry.NativeObject;
  
              DirectorySearcher search = new DirectorySearcher(entry);
              uName = domainAndUsername.Split('\\');
              search.Filter = "(SAMAccountName=" + uName[1] + ")";
              search.PropertiesToLoad.Add("cn");
              SearchResult result = search.FindOne();
  
              if (null == result)
              {
                  return false;
              }
  
              //Update the new path to the user in the directory.
              _path = result.Path;
              _filterAttribute = (string)result.Properties["cn"][0];
          }
          catch (Exception ex)
          {
              throw new Exception("Error authenticating user. " + ex.Message);
          }
  </code></pre>
  
  <p>I even commented the line and tested it. It worked fine too. I searched everywhere for an answer, never found one. Hope i'll get it here.. :)</p>