title: How to check the valid user's password matches with active directory
body: <p>I'm passing username and password to check whether a user is valid from Active Directory.</p>
  
  <p>Here is my code :</p>
  
  <pre><code>  private bool ValidUser(string name, string userPwd)
      {
  
          string UserName = "XXXXXXXXXX";
          string Password = "XXXXXXXXXXXXX";
          DirectoryEntry objRootEntry = new DirectoryEntry("XXXXXXXX.com", UserName, Password);
          DirectorySearcher objADSearcher = new DirectorySearcher(objRootEntry);
          objADSearcher.Filter = ("(&amp;(sAMAccountType=xxxxxxxxx)(samAccountName=" + name + "))");
          SearchResult objResult = objADSearcher.FindOne();
          DirectoryEntry objLoginEntry = (objResult != null) ? objResult.GetDirectoryEntry() : null;          
          if (objLoginEntry != null)
          {
              return true;
          }
          return false;
      }
  </code></pre>
  
  <p>Now it checks the user name alone.I need to check whether the entering password (userPwd) matches with the Active directory. How to do that.</p>
  
  <p>Please help me out.</p>