Esempio n. 1
0
        public static void RetrieveAuditPolicy(OrganizationId orgId, out AuditPolicyCacheEntry cacheEntry)
        {
            bool flag;

            if (!AuditPolicyCache.Instance.GetAuditPolicy(orgId, out cacheEntry, out flag, null) || flag)
            {
                PolicyAuditOperations policyAuditOperations;
                PolicyLoadStatus      loadStatus            = AuditPolicyUtility.LoadAuditableOperations(orgId, Workload.Exchange, out policyAuditOperations);
                AuditPolicyCacheEntry auditPolicyCacheEntry = new AuditPolicyCacheEntry((policyAuditOperations == null) ? MailboxAuditOperations.None : AuditPolicyUtility.ConvertPolicyOperationsToMailboxOperations(policyAuditOperations.AuditOperationsDelegate), loadStatus);
                AuditPolicyCache.Instance.UpdateAuditPolicy(orgId, ref auditPolicyCacheEntry, null);
                cacheEntry = auditPolicyCacheEntry;
            }
        }
Esempio n. 2
0
        public static PolicyLoadStatus LoadAuditableOperations(OrganizationId orgId, Workload workload, out PolicyAuditOperations auditOperations)
        {
            if (orgId == null)
            {
                auditOperations = null;
                return(PolicyLoadStatus.Unknown);
            }
            Exception             ex         = null;
            PolicyLoadStatus      loadStatus = PolicyLoadStatus.Unknown;
            PolicyAuditOperations operations = null;

            try
            {
                GrayException.MapAndReportGrayExceptions(delegate()
                {
                    AuditPolicyUtility.LoadAuditableOperationsInternal(orgId, workload, out loadStatus, out operations);
                });
            }
            catch (GrayException ex2)
            {
                ex = ex2;
            }
            catch (Exception ex3)
            {
                ex = ex3;
                ExWatson.SendReportAndCrashOnAnotherThread(ex3);
            }
            if (ex != null)
            {
                ExTraceGlobals.SessionTracer.TraceError <Workload, OrganizationId, Exception>(0L, "Error occurred while trying to load audit configuration for workload {0} of organization: '{1}'. Exception details: {2}", workload, orgId, ex);
                ProcessInfoEventLogger.Log(StorageEventLogConstants.Tuple_ErrorLoadAuditPolicyConfiguration, orgId.ToString(), new object[]
                {
                    workload,
                    orgId,
                    ex
                });
            }
            auditOperations = operations;
            return(loadStatus);
        }
Esempio n. 3
0
 public static bool CanUpdate(PolicyLoadStatus loadStatus, PolicyLoadStatus cachedStatus)
 {
     return(AuditPolicyCacheEntry.CanUpdateCachedEntry[(int)loadStatus][(int)cachedStatus]);
 }
Esempio n. 4
0
 public AuditPolicyCacheEntry(MailboxAuditOperations auditDelegateOperations = MailboxAuditOperations.None, PolicyLoadStatus loadStatus = PolicyLoadStatus.Unknown)
 {
     this.AuditOperationsDelegate = auditDelegateOperations;
     this.LoadStatus = loadStatus;
 }
Esempio n. 5
0
        private static void LoadAuditableOperationsInternal(OrganizationId orgId, Workload workload, out PolicyLoadStatus loadStatus, out PolicyAuditOperations operations)
        {
            loadStatus = PolicyLoadStatus.Unknown;
            operations = null;
            Guid guid;

            if (!AuditPolicyUtility.GetRuleGuidFromWorkload(workload, out guid))
            {
                return;
            }
            using (PolicyConfigProvider policyConfigProvider = PolicyConfigProviderManager <ExPolicyConfigProviderManager> .Instance.CreateForProcessingEngine(orgId))
            {
                if (policyConfigProvider != null)
                {
                    PolicyConfigConverterBase converterByType = PolicyConfigConverterTable.GetConverterByType(typeof(PolicyRuleConfig), true);
                    IConfigurable[]           array           = converterByType.GetFindStorageObjectsDelegate((ExPolicyConfigProvider)policyConfigProvider)(new ComparisonFilter(ComparisonOperator.Equal, ADObjectSchema.Name, guid.ToString()), ((ExPolicyConfigProvider)policyConfigProvider).GetPolicyConfigContainer(null), true, null);
                    if (array != null)
                    {
                        if (!array.Any <IConfigurable>())
                        {
                            loadStatus = PolicyLoadStatus.NotExist;
                        }
                        else
                        {
                            loadStatus = PolicyLoadStatus.FailedToLoad;
                            AuditConfigurationRule auditConfigurationRule = new AuditConfigurationRule((RuleStorage)array[0]);
                            auditConfigurationRule.PopulateTaskProperties();
                            loadStatus = PolicyLoadStatus.Loaded;
                            operations = new PolicyAuditOperations
                            {
                                AuditOperationsDelegate = auditConfigurationRule.AuditOperation
                            };
                        }
                    }
                }
            }
        }