title: DirectorySearcher.Filter return Users with birthday of current month
body: <p>I am trying to find all users with AD that have a birthday in the current month. I want this to be dynamic but anyways. I'm new to querying ldap and I'm have trouble writing the string that will filter the search. Currently I am getting all of the users and then using LINQ to sort through the list of returned users but I thought I would try just return the users from the AD Search. Right now I have:</p>
  
  <pre><code>System.DirectoryServices.DirectoryEntry entry = new System.DirectoryServices.DirectoryEntry(_path, username, pwd);
  
  System.DirectoryServices.DirectorySearcher mySearcher = new System.DirectoryServices.DirectorySearcher(entry);
  
  mySearcher.Filter = ("(objectClass=user)");
  </code></pre>
  
  <p>I believe the guy running AD has their B-days stored simply as a string in the format MMDD i.e. 0508. I can't do anything about that (if there is a better way there's nothing I can do about it). </p>
  
  <p>So what's the best way to approach this?</p>
  
  <p>Additional code if needed:</p>
  
  <pre><code>     SortOption option = new SortOption("sAMAccountName", System.DirectoryServices.SortDirection.Ascending);
  
          mySearcher.Sort = option;
  
          DataSet ds = new DataSet();
  
          DataTable dtUsers = new DataTable("Users");
  
          dtUsers.Columns.Add("userid");
  
          dtUsers.Columns.Add("name");
  
          dtUsers.Columns.Add("birthday");
  
          dtUsers.Columns.Add("anniversary");
  
          dtUsers.Constraints.Add("UniqueUserId", dtUsers.Columns["userid"], true);
  
  
  
          foreach (System.DirectoryServices.SearchResult resEnt in mySearcher.FindAll())
  
          {
  
          System.DirectoryServices.DirectoryEntry de1 = resEnt.GetDirectoryEntry();
  
          DataRow drUser = dtUsers.NewRow();
  
          if (de1.Properties["sAMAccountName"].Value != null &amp;&amp; de1.Properties["name"].Value != null &amp;&amp; de1.Properties["employeeBirthDate"].Value != null &amp;&amp; de1.Properties["employeeHireDate"].Value != null)
  
          {
  
  
  
          drUser["userid"] = de1.Properties["sAMAccountName"].Value.ToString();
  
          drUser["name"] = de1.Properties["name"].Value.ToString();
          drUser["birthday"] = de1.Properties["employeeBirthDate"].Value.ToString();
          drUser["anniversary"] = de1.Properties["employeeHireDate"].Value.ToString();
  
  
  
          dtUsers.Rows.Add(drUser);
  
          }
  
      }
  
      ds.Tables.Add(dtUsers);
  </code></pre>