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