Ejemplo n.º 1
0
 private static ScopeStorage ScopeStorageFromString(string scopeStorageString, ExPolicyConfigProvider policyConfigProvider)
 {
     if (!string.IsNullOrEmpty(scopeStorageString))
     {
         Guid     empty  = Guid.Empty;
         Mode     mode   = Mode.Enforce;
         Guid     empty2 = Guid.Empty;
         string[] array  = scopeStorageString.Split(new char[]
         {
             ','
         }, 5);
         if (array.Length == 5 && Guid.TryParse(array[0], out empty) && Enum.TryParse <Mode>(array[1], out mode) && Guid.TryParse(array[2], out empty2) && !string.IsNullOrEmpty(array[3]) && !string.IsNullOrEmpty(array[4]))
         {
             ScopeStorage scopeStorage = new ScopeStorage();
             scopeStorage.SetId(PolicyStorage.PoliciesContainer.GetChildId(empty.ToString()));
             scopeStorage.Name           = array[3];
             scopeStorage.MasterIdentity = empty;
             scopeStorage.PolicyVersion  = empty2;
             scopeStorage.Mode           = mode;
             scopeStorage.Scope          = array[4];
             scopeStorage.ResetChangeTracking(true);
             return(scopeStorage);
         }
     }
     policyConfigProvider.LogOneEntry(ExecutionLog.EventType.CriticalError, "Convert string to scope storage", new FormatException(string.Format("'{0}' is not valid for scope storage.", scopeStorageString)));
     return(null);
 }
        public static ScopeStorage ToScopeStorage(ScopeConfiguration scope)
        {
            ScopeStorage scopeStorage = new ScopeStorage();

            scopeStorage[ADObjectSchema.OrganizationalUnitRoot] = new ADObjectId(scope.TenantId);
            scopeStorage.Name = scope.Name;
            scopeStorage.SetId((ADObjectId)DalHelper.ConvertFromStoreObject(scope.ObjectId, typeof(ADObjectId)));
            UnifiedPolicyStorageFactory.CopyPropertiesToStorage <ScopeConfiguration>(new TenantSettingFacade <ScopeStorage>(scopeStorage), scope);
            return(scopeStorage);
        }
Ejemplo n.º 3
0
        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);
        }
Ejemplo n.º 4
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();
     }
 }