protected override void WriteResult(IConfigurable dataObject) { AuditConfigurationRule auditConfigurationRule = new AuditConfigurationRule(dataObject as RuleStorage); auditConfigurationRule.PopulateTaskProperties(); base.WriteResult(auditConfigurationRule); }
protected override IConfigurable PrepareDataObject() { RuleStorage ruleStorage = (RuleStorage)base.PrepareDataObject(); ruleStorage.Name = this.Name; ruleStorage.SetId(((ADObjectId)this.policyStorage.Identity).GetChildId(this.Name)); AuditConfigurationRule auditConfigurationRule = new AuditConfigurationRule(ruleStorage) { Policy = Utils.GetUniversalIdentity(this.policyStorage), Workload = this.policyStorage.Workload, AuditOperation = this.AuditOperation }; auditConfigurationRule.UpdateStorageProperties(); return(ruleStorage); }
protected override void StampChangesOn(IConfigurable dataObject) { RuleStorage ruleStorage = (RuleStorage)dataObject; ruleStorage.ResetChangeTracking(true); AuditConfigurationRule auditConfigurationRule = new AuditConfigurationRule(dataObject as RuleStorage); auditConfigurationRule.PopulateTaskProperties(); if (ruleStorage.Mode == Mode.PendingDeletion) { base.WriteError(new ErrorCommonComplianceRuleIsDeletedException(ruleStorage.Name), ErrorCategory.InvalidOperation, null); } base.StampChangesOn(dataObject); auditConfigurationRule.CopyChangesFrom(base.DynamicParametersInstance); auditConfigurationRule.AuditOperation = this.AuditOperation; auditConfigurationRule.UpdateStorageProperties(); }
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 }); } } } }
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 }; } } } } }
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); } } } } }
internal static AuditSwitchStatus ValidateAuditConfigurationRule(Workload workload, AuditConfigurationRule auditRule) { MultiValuedProperty <AuditableOperations> auditOperation = auditRule.AuditOperation; Tuple <MultiValuedProperty <AuditableOperations>, MultiValuedProperty <AuditableOperations> > tuple = AuditConfigUtility.auditMap[workload]; if (tuple != null) { if (auditOperation.Equals(tuple.Item1)) { return(AuditSwitchStatus.Off); } if (auditOperation.Equals(tuple.Item2)) { return(AuditSwitchStatus.On); } } return(AuditSwitchStatus.None); }