internal bool TryGetValue(TenantRelocationSyncObject obj, out ICustomObjectHandler handler) { bool flag = false; handler = null; MultiValuedProperty <string> multiValuedProperty = (MultiValuedProperty <string>)obj[ADObjectSchema.ObjectClass]; if (multiValuedProperty != null) { foreach (string key in multiValuedProperty) { flag = this.handlers.TryGetValue(key, out handler); if (flag) { break; } } } return(flag); }
private bool HandleSupportedSharedConfigurationsProperty(TenantRelocationSyncObject obj, ModifyRequest modRequest, UpdateData mData, TenantRelocationSyncData syncData, ITopologyConfigurationSession targetPartitionSession) { if (!TenantRelocationConfigImpl.GetConfig <bool>("TranslateSupportedSharedConfigurations")) { return(false); } DirectoryAttributeModification directoryAttributeModification = null; MultiValuedProperty <ADObjectId> multiValuedProperty = (MultiValuedProperty <ADObjectId>)obj[OrganizationSchema.SupportedSharedConfigurations]; MultiValuedProperty <ADObjectId> multiValuedProperty2; if (multiValuedProperty != null && multiValuedProperty.Count > 0) { OrganizationId organizationId = syncData.Source.OrganizationId; Exception ex; OrganizationId organizationId2 = SharedConfiguration.FindMostRecentSharedConfigurationInPartition(organizationId, syncData.Target.PartitionId, out ex); if (ex != null) { throw ex; } directoryAttributeModification = this.GetDirectoryAttributeModification(DirectoryAttributeOperation.Add); directoryAttributeModification.Add(organizationId2.ConfigurationUnit.DistinguishedName); modRequest.Modifications.Add(directoryAttributeModification); } else if (this.TryGetSupportedSharedConfigurations(targetPartitionSession, modRequest.DistinguishedName, syncData, out multiValuedProperty2) && multiValuedProperty2 != null && multiValuedProperty2.Count > 0) { directoryAttributeModification = this.GetDirectoryAttributeModification(DirectoryAttributeOperation.Delete); foreach (ADObjectId adobjectId in multiValuedProperty2) { directoryAttributeModification.Add(adobjectId.DistinguishedName); } modRequest.Modifications.Add(directoryAttributeModification); } if (directoryAttributeModification != null) { ExTraceGlobals.TenantRelocationTracer.TraceDebug <string, DirectoryAttributeOperation>((long)this.GetHashCode(), "GenerateModifyRequestLinkMetaDataHandler: add item: attribute {0}, op:{1}", directoryAttributeModification.Name, directoryAttributeModification.Operation); return(true); } return(false); }
public bool HandleObject(TenantRelocationSyncObject obj, ModifyRequest modRequest, UpdateData mData, TenantRelocationSyncData syncData, ITopologyConfigurationSession targetPartitionSession) { bool flag = false; return(flag | this.HandleSupportedSharedConfigurationsProperty(obj, modRequest, mData, syncData, targetPartitionSession)); }
private IEnumerable <ADRawEntry> ReadSpecialObjects() { ADObjectId exchangeServiceObject = base.RootOrgConfigurationSession.ConfigurationNamingContext.GetChildId("Services").GetChildId("Microsoft Exchange"); int numberOfLinksToRead = 1500; int rangeStart = 0; int rangeEnd = rangeStart + numberOfLinksToRead - 1; ADPropertyDefinition[] propertiesToRetrieve = new ADPropertyDefinition[] { ADObjectSchema.Id }; ADObjectId configUnitDn = new ADObjectId(this.PageToken.TenantConfigUnitObjectGuid); ADRawEntry dnResolve = base.TenantConfigurationSession.ReadADRawEntry(configUnitDn, propertiesToRetrieve); configUnitDn = dnResolve.Id; ExTraceGlobals.TenantRelocationTracer.TraceDebug <ADObjectId>((long)SyncConfiguration.TraceId, "TenantRelocationSyncConfiguration.ReadSpecialObjects tenant CU DN = {0}", configUnitDn); MultiValuedProperty <LinkMetadata> resultValues = new MultiValuedProperty <LinkMetadata>(); ADRawEntry entry = null; long maxEntryUSN = 0L; bool done = false; while (!done) { ADPropertyDefinition adpropertyDefinition = RangedPropertyHelper.CreateRangedProperty(ADRecipientSchema.LinkMetadata, new IntRange(rangeStart, rangeEnd)); List <PropertyDefinition> list = new List <PropertyDefinition>(); list.Add(adpropertyDefinition); list.Add(ADRecipientSchema.UsnChanged); entry = base.RootOrgConfigurationSession.RetrieveTenantRelocationSyncObject(exchangeServiceObject, list); ExTraceGlobals.TenantRelocationTracer.TraceDebug <string>((long)SyncConfiguration.TraceId, "TenantRelocationSyncConfiguration.ReadSpecialObjects object read: {0}", entry.Id.DistinguishedName); if ((long)entry[ADRecipientSchema.UsnChanged] < this.PageToken.SpecialObjectsUSN) { ExTraceGlobals.TenantRelocationTracer.TraceDebug <object, long>((long)SyncConfiguration.TraceId, "TenantRelocationSyncConfiguration.ReadSpecialObjects USNChanged({0} < this.PageToken.SpecialObjectsUSN({1})", entry[ADRecipientSchema.UsnChanged], this.PageToken.SpecialObjectsUSN); break; } MultiValuedProperty <LinkMetadata> multiValuedProperty = (MultiValuedProperty <LinkMetadata>)entry[adpropertyDefinition]; foreach (LinkMetadata linkMetadata in multiValuedProperty) { if (linkMetadata.LocalUpdateSequenceNumber >= this.PageToken.SpecialObjectsUSN) { ADObjectId adobjectId = new ADObjectId(linkMetadata.TargetDistinguishedName); if (adobjectId.IsDescendantOf(configUnitDn)) { ExTraceGlobals.TenantRelocationTracer.TraceDebug <string, long>((long)SyncConfiguration.TraceId, "TenantRelocationSyncConfiguration.ReadSpecialObjects valid link found: {0}, USN={1}", linkMetadata.TargetDistinguishedName, linkMetadata.LocalUpdateSequenceNumber); if (linkMetadata.LocalUpdateSequenceNumber > maxEntryUSN) { maxEntryUSN = linkMetadata.LocalUpdateSequenceNumber; } resultValues.Add(linkMetadata); } } } if (multiValuedProperty.ValueRange != null && multiValuedProperty.ValueRange.UpperBound != 2147483647) { rangeStart += numberOfLinksToRead; rangeEnd = rangeStart + numberOfLinksToRead - 1; ExTraceGlobals.TenantRelocationTracer.TraceDebug <int, int>((long)SyncConfiguration.TraceId, "TenantRelocationSyncConfiguration.ReadSpecialObjects retrieve next page: rangeStart={0}, rangeEnd={1}", rangeStart, rangeEnd); } else { done = true; ExTraceGlobals.TenantRelocationTracer.TraceDebug((long)SyncConfiguration.TraceId, "TenantRelocationSyncConfiguration.ReadSpecialObjects page retrieval ends"); } } this.PageToken.SpecialObjectsUSN = ((maxEntryUSN == 0L) ? long.MaxValue : (maxEntryUSN + 1L)); ExTraceGlobals.TenantRelocationTracer.TraceDebug <long>((long)SyncConfiguration.TraceId, "TenantRelocationSyncConfiguration.ReadSpecialObjects SpecialObjectsUSN is set to {0}", this.PageToken.SpecialObjectsUSN); ExTraceGlobals.TenantRelocationTracer.TraceDebug <int>((long)SyncConfiguration.TraceId, "TenantRelocationSyncConfiguration.ReadSpecialObjects Number of values found = {0}", resultValues.Count); if (resultValues.Count > 0) { ADPropertyBag propertyBag = new ADPropertyBag(); propertyBag.SetField(ADObjectSchema.Id, entry.Id); propertyBag.SetField(ADRecipientSchema.UsnChanged, entry[ADRecipientSchema.UsnChanged]); propertyBag.SetField(ADRecipientSchema.LinkMetadata, resultValues); propertyBag.SetField(SyncObjectSchema.Deleted, false); TenantRelocationSyncObject specialObject = new TenantRelocationSyncObject(propertyBag, new DirectoryAttribute[0]); yield return(specialObject); } yield break; }