#Applying Tenant Level Security to Scheduled Reports

##About

This code sample shows how to apply security for the owner of the report when it gets sent out via the scheduler. This can allow reports to get disseminated based on the report owner's tenant ID and prevent any users outside of that group from receiving the report.

public override void PreExecuteReportSet(Izenda.AdHoc.ReportSetreportSet)
  {
    bool scheduler = AdHocSettings.CurrentUserName.Equals("DefaultAdministrator");
    if (scheduler)
      {
        Filter f = new Filter("TenantID");
        f.Value = LookupTenantIDFromUser(reportSet.UserName); //Write your own implementation of this method
        reportSet.Filters.AddHidden(f);
      }
  } //end method