title: List of all users who were deactivated in the last month/given date range in Active directory
body: <p>I can able to find out if the user is Active or not in AD by below code.</p>
  
  <pre><code>public class ADService
  {
      public bool? FindAccountStatusByEmail(string email)
      {
          using (DirectorySearcher dSearch = new DirectorySearcher())
          {
              dSearch.Filter = "(&amp;(objectCategory=person)(sAMAccountName=*)(mail=" + email.Trim() + "))";
              SearchResult sResult = dSearch.FindOne();
              if (sResult != null)
              {
                  DirectoryEntry de = sResult.GetDirectoryEntry();
                  return IsActive(de);
              }
              else
              {
                  return null;
              }
          }
      }
      private bool IsActive(DirectoryEntry de)
      {
          if (de.NativeGuid == null) return false;
  
          int flags = (int)de.Properties["userAccountControl"].Value;
  
          return !Convert.ToBoolean(flags &amp; 0x0002);
      }
  }
  </code></pre>
  
  <p>But I need to generate a list of deactivated user in the last month/given date range in Active directory using C#. </p>
  
  <p>Can you please help me.</p>