title: Searching Active Directory users with a contains and OR query
body: <p>I've written this code to find users with a display name containing a certain string. I would like to improve this query so that it returns anyone that contains the string in either their <code>firstname</code> or <code>lastname</code> or <code>displayname</code> (right now its only filtering on displayname). </p>
  
  <p>Is that possible? I cant seem to find any examples using OR in these queries/filters.</p>
  
  <pre><code>List&lt;ADUser&gt; adUsers = new List&lt;ADUser&gt;();
  
  DirectoryEntry directoryEntry = Domain.GetCurrentDomain().GetDirectoryEntry();
  DirectorySearcher directorySearcher = new DirectorySearcher(directoryEntry);
  
  directorySearcher.PropertiesToLoad.Add("samaccountname");
  directorySearcher.PropertiesToLoad.Add("mail");
  directorySearcher.PropertiesToLoad.Add("usergroup");
  directorySearcher.PropertiesToLoad.Add("displayname");
  directorySearcher.PropertiesToLoad.Add("firstname");
  directorySearcher.PropertiesToLoad.Add("lastname");
  
  directorySearcher.Filter = "(&amp;(objectClass=User) (displayname=*" + searchQuery + "*))";
  
  SearchResultCollection searchResultCollection = directorySearcher.FindAll();
  foreach (SearchResult u in searchResultCollection)
  {
      var user = new ADUser()
      {
          UserName = u?.Properties?.Contains("samaccountname") == true ? u?.Properties["samaccountname"][0]?.ToString() : String.Empty,
          DisplayName = u?.Properties?.Contains("displayname") == true ? u?.Properties["displayname"][0]?.ToString() : String.Empty,
          FirstName = u?.Properties?.Contains("firstname") == true ? u?.Properties["firstname"][0]?.ToString() : String.Empty,
          LastName = u?.Properties?.Contains("lastname") == true ? u?.Properties["lastname"][0]?.ToString() : String.Empty,
          Email = u?.Properties?.Contains("mail") == true ? u?.Properties["mail"][0]?.ToString() : String.Empty,
          UserGroup = u?.Properties?.Contains("usergroup") == true ? u?.Properties["usergroup"][0]?.ToString() : String.Empty,
      };
      adUsers.Add(user);
  }
  </code></pre>