Example #1
0
        internal override IADOPathNode BuildSearchFilter(IADOPathNode filter)
        {
            MappingTable <AttributeConverterEntry> item         = ADNtdsSiteSettingFactory <ADNtdsSiteSetting> .AttributeTable[base.ConnectedStore];
            MappingTable <AttributeConverterEntry> mappingTable = ADReplicationSiteFactory <T> .AttributeTable[base.ConnectedStore];

            return(ADTopologyUtil.BuildSearchFilter(filter, mappingTable, item, base.CmdletSessionInfo));
        }
Example #2
0
 internal override T GetExtendedObjectFromIdentity(T identityObj, string identityQueryPath, ICollection <string> propertiesToFetch, bool showDeleted)
 {
     if (base.CmdletSessionInfo != null)
     {
         MappingTable <AttributeConverterEntry> item         = ADNtdsSiteSettingFactory <ADNtdsSiteSetting> .AttributeTable[base.ConnectedStore];
         MappingTable <AttributeConverterEntry> mappingTable = ADReplicationSiteFactory <T> .AttributeTable[base.ConnectedStore];
         ICollection <string> parentAttributes = ADTopologyUtil.GetParentAttributes(mappingTable, item, propertiesToFetch);
         ICollection <string> childAttributes  = ADTopologyUtil.GetChildAttributes(mappingTable, item, propertiesToFetch);
         T      extendedObjectFromIdentity     = base.GetExtendedObjectFromIdentity(identityObj, identityQueryPath, parentAttributes, showDeleted);
         string str = ADPathModule.MakePath(extendedObjectFromIdentity.DistinguishedName, "CN=NTDS Site Settings,", ADPathFormat.X500);
         try
         {
             ADTopologyUtil.ConstructAggregateObject <ADNtdsSiteSettingFactory <ADNtdsSiteSetting>, ADNtdsSiteSetting>(str, extendedObjectFromIdentity, identityQueryPath, childAttributes, showDeleted, base.CmdletSessionInfo);
         }
         catch (ADIdentityNotFoundException aDIdentityNotFoundException)
         {
             DebugLogger.LogInfo(this._debugCategory, string.Format("ADReplicationSiteFactory: Ntds-Site-Setting object not found for the site {0}, while constructing ADReplicationSite", extendedObjectFromIdentity.DistinguishedName));
         }
         return(extendedObjectFromIdentity);
     }
     else
     {
         throw new ArgumentNullException(StringResources.SessionRequired);
     }
 }
Example #3
0
        internal static IADOPathNode BuildSearchFilter(IADOPathNode filter, MappingTable <AttributeConverterEntry> attrMapBaseObj, MappingTable <AttributeConverterEntry> attrMapChildObj, CmdletSessionInfo sessionInfo)
        {
            BinaryADOPathNode binaryADOPathNode = filter as BinaryADOPathNode;

            if (binaryADOPathNode == null)
            {
                return(null);
            }
            else
            {
                string ldapFilterString = binaryADOPathNode.LeftNode.GetLdapFilterString();
                AttributeConverterEntry attributeConverterEntry = null;
                if (!attrMapBaseObj.TryGetValue(ldapFilterString, out attributeConverterEntry))
                {
                    if (!attrMapChildObj.TryGetValue(ldapFilterString, out attributeConverterEntry))
                    {
                        string[] strArrays = new string[1];
                        strArrays[0] = ldapFilterString;
                        return(SearchConverters.ToSearchObjectClientSideFilter(ldapFilterString, strArrays, filter, sessionInfo));
                    }
                    else
                    {
                        return(attributeConverterEntry.InvokeToSearcherConverter(filter, sessionInfo));
                    }
                }
                else
                {
                    return(attributeConverterEntry.InvokeToSearcherConverter(filter, sessionInfo));
                }
            }
        }
Example #4
0
 internal virtual IADOPathNode BuildSearchFilter(IADOPathNode filter)
 {
     if (this.CmdletSessionInfo != null)
     {
         MappingTable <AttributeConverterEntry> item = ADFactoryBase <T> .AttributeTable[this.ConnectedStore];
         BinaryADOPathNode binaryADOPathNode         = filter as BinaryADOPathNode;
         if (binaryADOPathNode == null)
         {
             return(null);
         }
         else
         {
             string ldapFilterString = binaryADOPathNode.LeftNode.GetLdapFilterString();
             AttributeConverterEntry attributeConverterEntry = null;
             if (!item.TryGetValue(ldapFilterString, out attributeConverterEntry))
             {
                 string[] strArrays = new string[1];
                 strArrays[0] = ldapFilterString;
                 return(SearchConverters.ToSearchUsingSchemaInfo(ldapFilterString, strArrays, filter, this.CmdletSessionInfo));
             }
             else
             {
                 return(attributeConverterEntry.InvokeToSearcherConverter(filter, this.CmdletSessionInfo));
             }
         }
     }
     else
     {
         throw new ArgumentNullException(StringResources.SessionRequired);
     }
 }
Example #5
0
        internal static ICollection <string> GetChildAttributes(MappingTable <AttributeConverterEntry> attrMapBaseObj, MappingTable <AttributeConverterEntry> attrMapChildObj, ICollection <string> propertiesToFetch)
        {
            AttributeConverterEntry attributeConverterEntry = null;
            HashSet <string>        strs = new HashSet <string>(StringComparer.OrdinalIgnoreCase);

            if (propertiesToFetch != null)
            {
                if (!propertiesToFetch.Contains("*"))
                {
                    foreach (string str in propertiesToFetch)
                    {
                        if (!attrMapChildObj.TryGetValue(str, out attributeConverterEntry) || attrMapBaseObj.TryGetValue(str, out attributeConverterEntry))
                        {
                            continue;
                        }
                        strs.Add(str);
                    }
                }
                else
                {
                    foreach (AttributeConverterEntry value in attrMapChildObj.Values)
                    {
                        strs.Add(value.ExtendedAttribute);
                    }
                }
            }
            return(strs);
        }
Example #6
0
        internal static void RemoveChildObjectAttributes(ADObject directoryObj, MappingTable <AttributeConverterEntry> attrMapBaseObj, MappingTable <AttributeConverterEntry> attrMapChildObj)
        {
            HashSet <string> strs = new HashSet <string>(attrMapChildObj.Keys, StringComparer.OrdinalIgnoreCase);

            strs.ExceptWith(attrMapBaseObj.Keys);
            foreach (string str in strs)
            {
                directoryObj.Remove(str);
                directoryObj.AddedProperties.Remove(str);
                directoryObj.RemovedProperties.Remove(str);
            }
        }
Example #7
0
 private bool ADReplicationSitePreCommitFSRoutine(ADFactory <T> .DirectoryOperation operation, T instance, ADParameterSet parameters, ADObject directoryObj)
 {
     if (ADFactory <T> .DirectoryOperation.Update == operation || operation == ADFactory <T> .DirectoryOperation.Create)
     {
         MappingTable <AttributeConverterEntry> item         = ADNtdsSiteSettingFactory <ADNtdsSiteSetting> .AttributeTable[base.ConnectedStore];
         MappingTable <AttributeConverterEntry> mappingTable = ADReplicationSiteFactory <T> .AttributeTable[base.ConnectedStore];
         ADTopologyUtil.RemoveChildObjectAttributes(directoryObj, mappingTable, item);
         return(true);
     }
     else
     {
         return(false);
     }
 }
Example #8
0
        internal override void UpdateFromObject(T modifiedObject, ADObject directoryObj)
        {
            AttributeConverterEntry attributeConverterEntry = null;

            if (modifiedObject.Contains("SuggestedValues"))
            {
                MappingTable <AttributeConverterEntry> item = ADClaimTypeBaseFactory <T> .AttributeTable[base.ConnectedStore];
                if (item.TryGetValue("SuggestedValues", out attributeConverterEntry))
                {
                    attributeConverterEntry.InvokeToDirectoryConverter(modifiedObject["SuggestedValues"], directoryObj, base.CmdletSessionInfo);
                }
            }
            base.UpdateFromObject(modifiedObject, directoryObj);
        }
Example #9
0
        internal static ICollection <string> GetDefaultPropertyFromMappingTable(MappingTable <AttributeConverterEntry> attrMapTable)
        {
            List <string> strs = new List <string>();

            foreach (AttributeConverterEntry value in attrMapTable.Values)
            {
                if (value.AttributeSet != AttributeSet.Default)
                {
                    continue;
                }
                strs.Add(value.ExtendedAttribute);
            }
            return(strs);
        }
Example #10
0
        internal static ICollection <string> GetParentAttributes(MappingTable <AttributeConverterEntry> attrMapBaseObj, MappingTable <AttributeConverterEntry> attrMapChildObj, ICollection <string> propertiesToFetch)
        {
            AttributeConverterEntry attributeConverterEntry = null;
            HashSet <string>        strs = new HashSet <string>(StringComparer.OrdinalIgnoreCase);

            if (propertiesToFetch != null)
            {
                foreach (string str in propertiesToFetch)
                {
                    if (!attrMapBaseObj.TryGetValue(str, out attributeConverterEntry) && attrMapChildObj.TryGetValue(str, out attributeConverterEntry))
                    {
                        continue;
                    }
                    strs.Add(str);
                }
            }
            return(strs);
        }
Example #11
0
        private static void RegisterMappingTable <MT>(Dictionary <ADServerType, MappingTable <MT> > table, MT[] map, ADServerType storeType)
            where MT : MappingTableEntry
        {
            if (!table.ContainsKey(storeType))
            {
                table.Add(storeType, new MappingTable <MT>());
            }
            MappingTable <MT> item = table[storeType];

            MT[] mTArray = map;
            for (int i = 0; i < (int)mTArray.Length; i++)
            {
                MT mT = mTArray[i];
                if (!item.ContainsKey(mT.ExtendedAttribute))
                {
                    item.Add(mT.ExtendedAttribute, mT);
                }
            }
        }
Example #12
0
 internal override IEnumerable <T> GetExtendedObjectFromFilter(IADOPathNode filter, string searchBase, ADSearchScope searchScope, ICollection <string> propertiesToFetch, int?resultSetSize, int?pageSize, bool showDeleted)
 {
     if (base.CmdletSessionInfo != null)
     {
         MappingTable <AttributeConverterEntry> item         = ADNtdsSiteSettingFactory <ADNtdsSiteSetting> .AttributeTable[base.ConnectedStore];
         MappingTable <AttributeConverterEntry> mappingTable = ADReplicationSiteFactory <T> .AttributeTable[base.ConnectedStore];
         ICollection <string> parentAttributes = ADTopologyUtil.GetParentAttributes(mappingTable, item, propertiesToFetch);
         ICollection <string> childAttributes  = ADTopologyUtil.GetChildAttributes(mappingTable, item, propertiesToFetch);
         if (!parentAttributes.Contains("*"))
         {
             parentAttributes.Add("*");
         }
         IEnumerable <T> extendedObjectFromFilter = base.GetExtendedObjectFromFilter(this.StructuralObjectFilter, searchBase, searchScope, parentAttributes, resultSetSize, pageSize, showDeleted);
         ADNtdsSiteSettingFactory <ADNtdsSiteSetting> aDNtdsSiteSettingFactory = new ADNtdsSiteSettingFactory <ADNtdsSiteSetting>();
         aDNtdsSiteSettingFactory.SetCmdletSessionInfo(base.CmdletSessionInfo);
         IEnumerable <ADNtdsSiteSetting>        aDNtdsSiteSettings = aDNtdsSiteSettingFactory.GetExtendedObjectFromFilter(aDNtdsSiteSettingFactory.StructuralObjectFilter, searchBase, searchScope, childAttributes, resultSetSize, pageSize, showDeleted);
         Dictionary <string, ADNtdsSiteSetting> strs = new Dictionary <string, ADNtdsSiteSetting>();
         foreach (ADNtdsSiteSetting aDNtdsSiteSetting in aDNtdsSiteSettings)
         {
             strs.Add(aDNtdsSiteSetting.DistinguishedName, aDNtdsSiteSetting);
         }
         List <T> ts = new List <T>();
         foreach (T t in extendedObjectFromFilter)
         {
             string str = ADPathModule.MakePath(t.DistinguishedName, "CN=NTDS Site Settings,", ADPathFormat.X500);
             if (strs.ContainsKey(str))
             {
                 ADNtdsSiteSetting item1 = strs[str];
                 ADTopologyUtil.MergeADObjectProperties(t, item1);
             }
             ts.Add(t);
         }
         IEnumerable <T> ts1 = this.ApplyClientSideFilter(ts);
         return(ADTopologyUtil.RemoveExtraPropertiesFromADAggregateObject <T>(mappingTable, item, propertiesToFetch, ts1));
     }
     else
     {
         throw new ArgumentNullException(StringResources.SessionRequired);
     }
 }
 internal virtual T Construct(ADEntity directoryObj)
 {
     if (base.CmdletSessionInfo != null)
     {
         T sessionInfo = Activator.CreateInstance <T>();
         sessionInfo.IsSearchResult = true;
         sessionInfo.SessionInfo    = directoryObj.SessionInfo;
         MappingTable <AttributeConverterEntry> item = ADFactoryBase <T> .AttributeTable[base.ConnectedStore];
         foreach (AttributeConverterEntry value in item.Values)
         {
             if (!value.IsExtendedConverterDefined)
             {
                 continue;
             }
             value.InvokeToExtendedConverter(sessionInfo, directoryObj, base.CmdletSessionInfo);
         }
         sessionInfo.TrackChanges = true;
         return(sessionInfo);
     }
     else
     {
         throw new ArgumentNullException(StringResources.SessionRequired);
     }
 }
Example #14
0
        private void CreateSiteChildObjects(ADFactory <T> .DirectoryOperation operation, T instance, ADParameterSet parameters, ADObject directoryObj)
        {
            AttributeConverterEntry attributeConverterEntry = null;
            bool flag = ADFactory <T> .DirectoryOperation.Create == operation;
            MappingTable <AttributeConverterEntry>          item         = ADNtdsSiteSettingFactory <ADNtdsSiteSetting> .AttributeTable[base.ConnectedStore];
            MappingTable <AttributeConverterEntry>          mappingTable = ADReplicationSiteFactory <T> .AttributeTable[base.ConnectedStore];
            IDictionary <string, ADPropertyValueCollection> strs         = new Dictionary <string, ADPropertyValueCollection>();

            if (instance != null)
            {
                foreach (string propertyName in instance.PropertyNames)
                {
                    if (flag && instance[propertyName].Value == null || mappingTable.TryGetValue(propertyName, out attributeConverterEntry) || !item.TryGetValue(propertyName, out attributeConverterEntry))
                    {
                        continue;
                    }
                    strs.Add(propertyName, instance[propertyName]);
                }
            }
            IDictionary <string, ADPropertyValueCollection> aDPVCDictionary = parameters.GetADPVCDictionary();

            foreach (string key in aDPVCDictionary.Keys)
            {
                if (mappingTable.TryGetValue(key, out attributeConverterEntry) || !item.TryGetValue(key, out attributeConverterEntry))
                {
                    continue;
                }
                if (!strs.ContainsKey(key))
                {
                    strs.Add(key, aDPVCDictionary[key]);
                }
                else
                {
                    strs[key] = aDPVCDictionary[key];
                }
            }
            string str = ADPathModule.MakePath(directoryObj.DistinguishedName, "CN=NTDS Site Settings,", ADPathFormat.X500);
            ADNtdsSiteSettingFactory <ADNtdsSiteSetting> aDNtdsSiteSettingFactory = new ADNtdsSiteSettingFactory <ADNtdsSiteSetting>();

            aDNtdsSiteSettingFactory.SetCmdletSessionInfo(base.CmdletSessionInfo);
            ADObject directoryObjectFromIdentity = null;

            if (!flag)
            {
                try
                {
                    ADNtdsSiteSetting aDNtdsSiteSetting = new ADNtdsSiteSetting(str);
                    directoryObjectFromIdentity = aDNtdsSiteSettingFactory.GetDirectoryObjectFromIdentity(aDNtdsSiteSetting, directoryObj.DistinguishedName);
                }
                catch (ADIdentityNotFoundException aDIdentityNotFoundException)
                {
                    DebugLogger.LogInfo(this._debugCategory, string.Format("ADReplicationSiteFactory: Ntds-Site-Setting object not found for the site {0}, while updating the properties of the ntds-site-settings", directoryObj.DistinguishedName));
                }
            }
            if (directoryObjectFromIdentity == null)
            {
                flag = true;
                directoryObjectFromIdentity = new ADObject(str, aDNtdsSiteSettingFactory.StructuralObjectClass);
            }
            foreach (string key1 in strs.Keys)
            {
                if (!item.TryGetValue(key1, out attributeConverterEntry) || !attributeConverterEntry.IsDirectoryConverterDefined)
                {
                    continue;
                }
                attributeConverterEntry.InvokeToDirectoryConverter(strs[key1], directoryObjectFromIdentity, base.CmdletSessionInfo);
            }
            using (ADActiveObject aDActiveObject = new ADActiveObject(base.CmdletSessionInfo.ADSessionInfo, directoryObjectFromIdentity))
            {
                if (!flag)
                {
                    aDActiveObject.Update();
                }
                else
                {
                    aDActiveObject.Create();
                }
            }
            if (operation == ADFactory <T> .DirectoryOperation.Create)
            {
                this.CreateServerContainer(directoryObj.DistinguishedName);
            }
        }
Example #15
0
        internal static IEnumerable <O> RemoveExtraPropertiesFromADAggregateObject <O>(MappingTable <AttributeConverterEntry> attrMapBaseObj, MappingTable <AttributeConverterEntry> attrMapChildObj, ICollection <string> propertiesToFetch, IEnumerable <O> aggregateObjectList)
            where O : ADEntity, new()
        {
            List <string> strs = null;

            if (propertiesToFetch == null || !propertiesToFetch.Contains("*"))
            {
                IEnumerable <string> defaultPropertyFromMappingTable  = ADTopologyUtil.GetDefaultPropertyFromMappingTable(attrMapBaseObj);
                IEnumerable <string> defaultPropertyFromMappingTable1 = ADTopologyUtil.GetDefaultPropertyFromMappingTable(attrMapChildObj);
                HashSet <string>     strs1 = new HashSet <string>(defaultPropertyFromMappingTable, StringComparer.OrdinalIgnoreCase);
                strs1.UnionWith(defaultPropertyFromMappingTable1);
                if (propertiesToFetch != null)
                {
                    strs1.UnionWith(propertiesToFetch);
                }
                foreach (O o in aggregateObjectList)
                {
                    o.TrackChanges = false;
                    strs           = new List <string>();
                    foreach (string propertyName in o.PropertyNames)
                    {
                        if (strs1.Contains(propertyName))
                        {
                            continue;
                        }
                        strs.Add(propertyName);
                    }
                    List <string> .Enumerator enumerator = strs.GetEnumerator();
                    try
                    {
                        while (enumerator.MoveNext())
                        {
                            string str = enumerator.Current;
                            o.Remove(str);
                        }
                    }
                    finally
                    {
                        enumerator.Dispose();
                    }
                    o.TrackChanges = true;
                }
                return(aggregateObjectList);
            }
            else
            {
                return(aggregateObjectList);
            }
        }