예제 #1
0
        protected override void InternalProcessRecord()
        {
            Func <ErrorRecord, bool> predicate = (ErrorRecord e) => !(e.Exception is ManagementObjectNotFoundException);

            foreach (Workload workload in AuditConfigUtility.AuditableWorkloads)
            {
                IEnumerable <ErrorRecord> errRecords;
                AuditConfigurationPolicy  auditConfigurationPolicy = AuditConfigUtility.GetAuditConfigurationPolicy(workload, this.Organization, out errRecords);
                if (AuditConfigUtility.ValidateErrorRecords(this, errRecords, predicate) && auditConfigurationPolicy != null)
                {
                    AuditConfigurationRule auditConfigurationRule = AuditConfigUtility.GetAuditConfigurationRule(workload, this.Organization, out errRecords);
                    if (AuditConfigUtility.ValidateErrorRecords(this, errRecords, predicate) && auditConfigurationRule != null)
                    {
                        this.WriteResult(new AuditConfig(workload)
                        {
                            Setting = AuditConfigUtility.ValidateAuditConfigurationRule(workload, auditConfigurationRule),
                            PolicyDistributionStatus = PolicyApplyStatus.Success,
                            DistributionResults      = auditConfigurationPolicy.DistributionResults
                        });
                    }
                }
            }
        }
예제 #2
0
        protected override void InternalProcessRecord()
        {
            Func <ErrorRecord, bool> predicate = (ErrorRecord e) => !(e.Exception is ManagementObjectNotFoundException);

            foreach (Workload workload in AuditConfigUtility.AuditableWorkloads)
            {
                AuditSwitchStatus auditSwitch = this.Workload.Contains(workload) ? AuditSwitchStatus.On : AuditSwitchStatus.Off;
                MultiValuedProperty <AuditableOperations> auditOperations = AuditConfigUtility.GetAuditOperations(workload, auditSwitch);
                IEnumerable <ErrorRecord> errRecords;
                AuditConfigurationRule    auditConfigurationRule = AuditConfigUtility.GetAuditConfigurationRule(workload, this.Organization, out errRecords);
                if (AuditConfigUtility.ValidateErrorRecords(this, errRecords, predicate))
                {
                    if (auditConfigurationRule != null)
                    {
                        AuditConfigUtility.SetAuditConfigurationRule(workload, this.Organization, auditOperations, out errRecords);
                        AuditConfigUtility.ValidateErrorRecords(this, errRecords);
                    }
                    else
                    {
                        AuditConfigurationPolicy auditConfigurationPolicy = AuditConfigUtility.GetAuditConfigurationPolicy(workload, this.Organization, out errRecords);
                        if (AuditConfigUtility.ValidateErrorRecords(this, errRecords, predicate))
                        {
                            if (auditConfigurationPolicy == null)
                            {
                                auditConfigurationPolicy = AuditConfigUtility.NewAuditConfigurationPolicy(workload, this.Organization, out errRecords);
                                if (!AuditConfigUtility.ValidateErrorRecords(this, errRecords))
                                {
                                    continue;
                                }
                            }
                            auditConfigurationRule = AuditConfigUtility.NewAuditConfigurationRule(workload, this.Organization, auditOperations, out errRecords);
                            AuditConfigUtility.ValidateErrorRecords(this, errRecords);
                        }
                    }
                }
            }
        }