Example #1
0
        public string CreateAuditTrailReport()
        {
            SecurityContext.DemandPermissions(SecutiryConstants.EditPortalSettings);

            var tenantId = TenantProvider.CurrentTenantID;

            if (!SetupInfo.IsVisibleSettings(ManagementType.AuditTrail.ToString()) ||
                CoreContext.Configuration.Standalone && !CoreContext.TenantManager.GetTenantQuota(tenantId).Audit)
            {
                throw new BillingException(Resource.ErrorNotAllowedOption, "Audit");
            }

            var settings = TenantAuditSettings.LoadForTenant(tenantId);

            var to   = DateTime.UtcNow;
            var from = to.Subtract(TimeSpan.FromDays(settings.AuditTrailLifeTime));

            var reportName = string.Format(AuditReportResource.AuditTrailReportName + ".csv", from.ToString("MM.dd.yyyy"), to.ToString("MM.dd.yyyy"));

            var events = AuditEventsRepository.Get(tenantId, from, to);
            var result = AuditReportCreator.CreateCsvReport(events, reportName);

            MessageService.Send(Request, MessageAction.AuditTrailReportDownloaded);
            return(result);
        }
Example #2
0
        public TenantAuditSettings GetAuditSettings()
        {
            SecurityContext.DemandPermissions(SecutiryConstants.EditPortalSettings);

            DemandBaseAuditPermission();

            return(TenantAuditSettings.LoadForTenant(TenantProvider.CurrentTenantID));
        }
Example #3
0
 public TenantAuditSettings GetAuditSettings()
 {
     if (!SetupInfo.IsVisibleSettings(ManagementType.LoginHistory.ToString()))
     {
         throw new BillingException(Resource.ErrorNotAllowedOption, "Audit");
     }
     SecurityContext.DemandPermissions(SecutiryConstants.EditPortalSettings);
     return(TenantAuditSettings.LoadForTenant(TenantProvider.CurrentTenantID));
 }
Example #4
0
        public string CreateLoginHistoryReport()
        {
            SecurityContext.DemandPermissions(SecutiryConstants.EditPortalSettings);

            DemandAuditPermission();

            var tenantId = TenantProvider.CurrentTenantID;

            var settings = TenantAuditSettings.LoadForTenant(tenantId);

            var to   = DateTime.UtcNow;
            var from = to.Subtract(TimeSpan.FromDays(settings.LoginHistoryLifeTime));

            var reportName = string.Format(AuditReportResource.LoginHistoryReportName + ".csv", from.ToShortDateString(), to.ToShortDateString());
            var events     = LoginEventsRepository.GetByFilter(from: from, to: to);
            var result     = AuditReportCreator.CreateCsvReport(events, reportName);

            MessageService.Send(Request, MessageAction.LoginHistoryReportDownloaded);
            return(result);
        }
Example #5
0
        private static void DeleteOldEvents(object state)
        {
            try
            {
                using (var db = DbManager.FromHttpContext(MessagesDbId))
                {
                    var activeTenants = CoreContext.TenantManager.GetTenants().Select(t => t.TenantId);

                    foreach (var tenant in activeTenants)
                    {
                        var settings = TenantAuditSettings.LoadForTenant(tenant);
                        DeleteOldEvents(db, LoginEventsTable, tenant, DateTime.UtcNow.Subtract(TimeSpan.FromDays(settings.LoginHistoryLifeTime)));
                        DeleteOldEvents(db, AuditEventsTable, tenant, DateTime.UtcNow.Subtract(TimeSpan.FromDays(settings.AuditTrailLifeTime)));
                    }
                }
            }
            catch (Exception ex)
            {
                log4net.LogManager.GetLogger("ASC.Messaging").Error(ex.Message, ex);
            }
        }
Example #6
0
        public string CreateLoginHistoryReport()
        {
            SecurityContext.DemandPermissions(SecutiryConstants.EditPortalSettings);

            var tenantId = TenantProvider.CurrentTenantID;

            if (!TenantExtra.GetTenantQuota().Audit || !SetupInfo.IsVisibleSettings(ManagementType.LoginHistory.ToString()))
            {
                throw new BillingException(Resource.ErrorNotAllowedOption, "Audit");
            }

            var settings = TenantAuditSettings.LoadForTenant(tenantId);

            var to   = DateTime.UtcNow;
            var from = to.Subtract(TimeSpan.FromDays(settings.LoginHistoryLifeTime));

            var reportName = string.Format(AuditReportResource.LoginHistoryReportName + ".csv", from.ToShortDateString(), to.ToShortDateString());
            var events     = LoginEventsRepository.Get(tenantId, from, to);
            var result     = AuditReportCreator.CreateCsvReport(events, reportName);

            MessageService.Send(Request, MessageAction.LoginHistoryReportDownloaded);
            return(result);
        }