private static ScopeStorage ToStorageScope(PolicyBindingConfig bindingScope, ADObjectId organizationalUnitRoot) { ScopeStorage scopeStorage = new ScopeStorage(); scopeStorage[ADObjectSchema.OrganizationalUnitRoot] = organizationalUnitRoot; scopeStorage.SetId(new ADObjectId(PolicyStorage.PoliciesContainer.GetChildId(bindingScope.Identity.ToString()).DistinguishedName, bindingScope.Identity)); scopeStorage.MasterIdentity = bindingScope.Identity; PolicyConfigConverterTable.UpdateStorageScope(scopeStorage, bindingScope); return(scopeStorage); }
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 }; } } } } }
static PolicyConfigConverterTable() { PolicyConfigConverterBase[] array = new PolicyConfigConverterBase[4]; array[0] = new PolicyConfigConverter <PolicyDefinitionConfig, PolicyStorage>(ExPolicyConfigProvider.IsFFOOnline ? ADObjectSchema.Id : UnifiedPolicyStorageBaseSchema.MasterIdentity, ConfigurationObjectType.Policy, delegate(PolicyStorage storage, PolicyDefinitionConfig policyConfig) { policyConfig.Mode = storage.Mode; policyConfig.Scenario = storage.Scenario; policyConfig.DefaultPolicyRuleConfigId = storage.DefaultRuleId; policyConfig.Comment = storage.Comments; policyConfig.Description = storage.Description; policyConfig.Enabled = storage.IsEnabled; policyConfig.CreatedBy = storage.CreatedBy; policyConfig.LastModifiedBy = storage.LastModifiedBy; }, delegate(PolicyDefinitionConfig policyConfig, PolicyStorage storage) { if (policyConfig.Mode != storage.Mode) { storage.Mode = policyConfig.Mode; } storage.Scenario = policyConfig.Scenario; storage.DefaultRuleId = policyConfig.DefaultPolicyRuleConfigId; storage.Comments = policyConfig.Comment; storage.Description = policyConfig.Description; storage.IsEnabled = policyConfig.Enabled; storage.CreatedBy = policyConfig.CreatedBy; storage.LastModifiedBy = policyConfig.LastModifiedBy; }); array[1] = new PolicyConfigConverter <PolicyRuleConfig, RuleStorage>(RuleStorageSchema.ParentPolicyId, ConfigurationObjectType.Rule, delegate(RuleStorage storage, PolicyRuleConfig policyConfig) { policyConfig.Mode = storage.Mode; policyConfig.PolicyDefinitionConfigId = storage.ParentPolicyId; policyConfig.Priority = storage.Priority; policyConfig.RuleBlob = storage.RuleBlob; policyConfig.Comment = storage.Comments; policyConfig.Description = storage.Description; policyConfig.Enabled = storage.IsEnabled; policyConfig.CreatedBy = storage.CreatedBy; policyConfig.LastModifiedBy = storage.LastModifiedBy; policyConfig.Scenario = storage.Scenario; }, delegate(PolicyRuleConfig policyConfig, RuleStorage storage) { if (policyConfig.Mode != storage.Mode) { storage.Mode = policyConfig.Mode; } storage.ParentPolicyId = policyConfig.PolicyDefinitionConfigId; storage.Priority = policyConfig.Priority; storage.RuleBlob = policyConfig.RuleBlob; storage.Comments = policyConfig.Comment; storage.Description = policyConfig.Description; storage.IsEnabled = policyConfig.Enabled; storage.CreatedBy = policyConfig.CreatedBy; storage.LastModifiedBy = policyConfig.LastModifiedBy; storage.Scenario = policyConfig.Scenario; }); array[2] = new PolicyConfigConverter <PolicyBindingSetConfig, BindingStorage>(BindingStorageSchema.PolicyId, ConfigurationObjectType.Binding, delegate(BindingStorage storage, PolicyBindingSetConfig policyConfig) { policyConfig.PolicyDefinitionConfigId = storage.PolicyId; List <PolicyBindingConfig> list = new List <PolicyBindingConfig>(storage.AppliedScopes.Count); foreach (ScopeStorage storageScope in storage.AppliedScopes) { PolicyBindingConfig policyBindingConfig = PolicyConfigConverterTable.ToBindingScope(storageScope); policyBindingConfig.PolicyDefinitionConfigId = storage.PolicyId; list.Add(policyBindingConfig); } policyConfig.AppliedScopes = list; }, delegate(PolicyBindingSetConfig policyConfig, BindingStorage storage) { PolicyConfigConverterTable.< > c__DisplayClass12 CS$ < > 8__locals1 = new PolicyConfigConverterTable.< > c__DisplayClass12(); CS$ < > 8__locals1.storage = storage; CS$ < > 8__locals1.storage.PolicyId = policyConfig.PolicyDefinitionConfigId; IEnumerable <PolicyBindingConfig> enumerable = policyConfig.AppliedScopes ?? ((IEnumerable <PolicyBindingConfig>)Array <PolicyBindingConfig> .Empty); int index; for (index = CS$ < > 8__locals1.storage.AppliedScopes.Count - 1; index >= 0; index--) { if (!enumerable.Any((PolicyBindingConfig bindingScope) => PolicyConfigConverterTable.IsSameScope(bindingScope, CS$ < > 8__locals1.storage.AppliedScopes[index]))) { CS$ < > 8__locals1.storage.AppliedScopes.RemoveAt(index); } } using (IEnumerator <PolicyBindingConfig> enumerator = enumerable.GetEnumerator()) { while (enumerator.MoveNext()) { PolicyBindingConfig bindingScope = enumerator.Current; ScopeStorage scopeStorage = CS$ < > 8__locals1.storage.AppliedScopes.FirstOrDefault((ScopeStorage scope) => PolicyConfigConverterTable.IsSameScope(bindingScope, scope)); if (scopeStorage == null) { CS$ < > 8__locals1.storage.AppliedScopes.Add(PolicyConfigConverterTable.ToStorageScope(bindingScope, CS$ < > 8__locals1.storage.OrganizationalUnitRoot)); } else { PolicyConfigConverterTable.UpdateStorageScope(scopeStorage, bindingScope); } } } }); array[3] = new PolicyConfigConverter <PolicyAssociationConfig, AssociationStorage>(AssociationStorageSchema.PolicyIds, ConfigurationObjectType.Association, delegate(AssociationStorage storage, PolicyAssociationConfig policyConfig) { throw new NotImplementedException("Not in v1 of unified policy."); }, delegate(PolicyAssociationConfig policyConfig, AssociationStorage storage) { throw new NotImplementedException("Not in v1 of unified policy."); }); PolicyConfigConverterTable.policyConverters = array; }