title: Check if user exists in Active Directory
body: <p>I am using vb.net and I want to check whether a particular user exists in Active Directory. If it does, I want to display the particular user's details. How to do it?</p>
  
  <p>User login credentials are passed via textbox control </p>
  
  <p>My code:</p>
  
  <pre><code> Dim de As DirectoryEntry = GetDirectoryEntry()
   Dim ds As DirectorySearcher = New DirectorySearcher(de)
    ds.Filter = "(&amp;(objectClass=txt1.text))"
  
      ' Use the FindAll method to return objects to SearchResultCollection.
      results = ds.FindAll()
  
  Public Shared Function GetDirectoryEntry() As DirectoryEntry
      Dim dirEntry As DirectoryEntry = New DirectoryEntry()
      dirEntry.Path = "LDAP://ss.in:389/CN=Schema,CN=Configuration,DC=ss,DC=in"
      dirEntry.Username = "ss.in\ssldap"
      dirEntry.Password = "ss@123"
      'Dim searcher As New DirectorySearcher
      'searcher.SearchRoot = dirEntry
      Return dirEntry
  End Function
  </code></pre>
  
  <p>Where I pass the password. Is this code is correct? I am new to AD. Pls help me to do this?</p>