Esempio n. 1
0
        private static void ModifyBatchGroups(KeyedOguObjectCollection groups, int startIndex, int batchSize, SynchronizeContext context)
        {
            //Key是AD Guid,Value是Ogu ID
            Dictionary <string, string> adToOguMapping = GetADToOguMappingFromGroups(groups, startIndex, batchSize, context);

            string[] propertiesToGet            = { "objectguid", "member" };
            IEnumerable <SearchResult> adGroups = SynchronizeHelper.GetSearchResultsByIDs(context.ADHelper, adToOguMapping.Keys, propertiesToGet, batchSize);

            foreach (SearchResult adGroup in adGroups)
            {
                SynchronizeContext.Current.ExtendLockTime();

                string guid = AttributeHelper.Hex((byte[])adGroup.Properties["objectguid"][0]);

                ADGroupMemberCollection adGroupMembers = new ADGroupMemberCollection(adGroup.Properties["member"], new string[] { "objectGUID" });

                Dictionary <string, ADObjectWrapper> adMemberDict = adGroupMembers.ToDictionary(o => o.NativeGuid);
                IGroup oguGroup = (IGroup)groups[adToOguMapping[guid]];

                if (IsSameMembers(oguGroup.Members, adMemberDict) == false)
                {
                    SyncGroupMembers(oguGroup, adGroup, context);
                }
            }
        }
Esempio n. 2
0
        private static void ModifyGroups(KeyedOguObjectCollection groups, SynchronizeContext context)
        {
            for (int i = 0; i < groups.Count / SynchronizeHelper.ADQueryBatchSize; i++)
            {
                ModifyBatchGroups(groups, (i * SynchronizeHelper.ADQueryBatchSize), SynchronizeHelper.ADQueryBatchSize, context);
            }

            ModifyBatchGroups(groups, groups.Count / SynchronizeHelper.ADQueryBatchSize, groups.Count % SynchronizeHelper.ADQueryBatchSize, context);
        }
Esempio n. 3
0
        private static Dictionary <string, string> GetADToOguMappingFromGroups(KeyedOguObjectCollection groups, int startIndex, int batchSize, SynchronizeContext context)
        {
            Dictionary <string, string> result = new Dictionary <string, string>();

            for (int i = startIndex; i < startIndex + batchSize; i++)
            {
                SynchronizeContext.Current.ExtendLockTime();

                IDMapping mapping = context.IDMapper.GetAdObjectMapping(groups[i].ID);

                result.Add(mapping.ADObjectGuid, mapping.SCObjectID);
            }

            return(result);
        }