Beispiel #1
0
 private static void UpdateStorageScope(ScopeStorage storageScope, PolicyBindingConfig bindingScope)
 {
     storageScope.Name = bindingScope.Name;
     if (storageScope.Mode != bindingScope.Mode)
     {
         storageScope.Mode = bindingScope.Mode;
     }
     storageScope.Scope         = BindingMetadata.ToStorage(bindingScope.Scope);
     storageScope.PolicyVersion = ((bindingScope.Version != null) ? bindingScope.Version.InternalStorage : Guid.Empty);
 }
Beispiel #2
0
 internal static void PopulateScopeStorages(BindingStorage bindingStorage, MultiValuedProperty <BindingMetadata> scopes)
 {
     ArgumentValidator.ThrowIfNull("bindingStorage", bindingStorage);
     ArgumentValidator.ThrowIfNull("scopes", scopes);
     if (scopes.Changed)
     {
         object[] removed = scopes.Removed;
         for (int i = 0; i < removed.Length; i++)
         {
             BindingMetadata removedScope = (BindingMetadata)removed[i];
             ScopeStorage    scopeStorage = bindingStorage.AppliedScopes.Find((ScopeStorage item) => string.Equals(BindingMetadata.FromStorage(item.Scope).ImmutableIdentity, removedScope.ImmutableIdentity, StringComparison.OrdinalIgnoreCase));
             scopeStorage.Mode          = Mode.PendingDeletion;
             scopeStorage.PolicyVersion = CombGuidGenerator.NewGuid();
         }
         object[] added = scopes.Added;
         for (int j = 0; j < added.Length; j++)
         {
             BindingMetadata addedScope    = (BindingMetadata)added[j];
             ScopeStorage    scopeStorage2 = bindingStorage.AppliedScopes.Find((ScopeStorage item) => string.Equals(BindingMetadata.FromStorage(item.Scope).ImmutableIdentity, addedScope.ImmutableIdentity, StringComparison.OrdinalIgnoreCase));
             if (scopeStorage2 == null)
             {
                 Guid objectGuid = Guid.NewGuid();
                 scopeStorage2 = new ScopeStorage();
                 scopeStorage2[ADObjectSchema.OrganizationalUnitRoot] = bindingStorage.OrganizationalUnitRoot;
                 scopeStorage2.Name = objectGuid.ToString();
                 scopeStorage2.SetId(new ADObjectId(PolicyStorage.PoliciesContainer.GetChildId(scopeStorage2.Name).DistinguishedName, objectGuid));
                 bindingStorage.AppliedScopes.Add(scopeStorage2);
             }
             scopeStorage2.Mode          = Mode.Enforce;
             scopeStorage2.Scope         = BindingMetadata.ToStorage(addedScope);
             scopeStorage2.PolicyVersion = CombGuidGenerator.NewGuid();
         }
         bindingStorage.PolicyVersion = CombGuidGenerator.NewGuid();
         scopes.ResetChangeTracking();
     }
 }