title: How to search users in LDAP using LdapConnection object in C#?
body: <p>I have requirement to search for users in a LDAP directory using C#. I can do it using <code>DirectoryEntry</code> and <code>DirectorySearcher</code> as shown in code below:</p>
  
  <pre><code>SearchResultCollection sResults = null;
  
  DirectoryEntry dEntry = new DirectoryEntry(_LDAPConnectionString);
  
  DirectorySearcher dSearcher = new DirectorySearcher(dEntry);    
  dSearcher.Filter = String.Format("(&amp;(objectClass=user)(cn={0}))", userName);
  
  sResults = dSearcher.FindAll();
  </code></pre>
  
  <p>But the requirement is to create a <code>LdapConnection</code> object using a standard access user (always the same) as shown below. And use that particular <code>LdapConnectionObject</code> to search users using username. </p>
  
  <pre><code>LdapConnection ldapConnectionObject = new LdapConnection(
                  new LdapDirectoryIdentifier(_hostName, _port),
                  null,
                  AuthType.Basic);
  ldapConnectionObject.Bind(accessUserCredential);
  </code></pre>
  
  <p>How do I use the above <code>ldapConnectionObject</code> to search for users? </p>