Esempio n. 1
0
 protected override void InternalProcessRecord()
 {
     TaskLogger.LogEnter();
     try
     {
         ExchangePrincipal mailboxOwner = ExchangePrincipal.FromADUser(this.DataObject, null);
         using (MailboxSession mailboxSession = MailboxSession.OpenAsAdmin(mailboxOwner, CultureInfo.InvariantCulture, "Client=Management;Action=Set-MailboxAssociationReplicationState"))
         {
             if (this.Instance.NextReplicationTime != null)
             {
                 LocalAssociationStore.SaveMailboxSyncStatus(mailboxSession, this.Instance.NextReplicationTime, null);
             }
         }
     }
     catch (StorageTransientException exception)
     {
         base.WriteError(exception, ErrorCategory.ReadError, this.Identity);
     }
     catch (StoragePermanentException exception2)
     {
         base.WriteError(exception2, ErrorCategory.ReadError, this.Identity);
     }
     finally
     {
         TaskLogger.LogExit();
     }
 }
        // Token: 0x06001534 RID: 5428 RVA: 0x00079274 File Offset: 0x00077474
        private void PerformDataReplication(MailboxSession mailboxSession, InvokeArgs invokeArgs)
        {
            IRecipientSession adSession            = DirectorySessionFactory.Default.GetTenantOrRootOrgRecipientSession(true, ConsistencyMode.IgnoreInvalid, mailboxSession.GetADSessionSettings(), 139, "PerformDataReplication", "f:\\15.00.1497\\sources\\dev\\MailboxAssistants\\src\\assistants\\MailboxAssociation\\MailboxAssociationReplicationAssistant.cs");
            string            operationDescription = MailboxAssociationReplicationAssistant.GetOperationDescription(invokeArgs.Parameters);

            GroupMailboxAccessLayer.Execute(operationDescription, adSession, mailboxSession, delegate(GroupMailboxAccessLayer accessLayer)
            {
                ADObjectId objectId = invokeArgs.StoreSession.MailboxOwner.ObjectId;
                MailboxAssociationReplicationAssistant.Tracer.TraceDebug <ADObjectId>((long)this.GetHashCode(), "MailboxAssociationReplicationAssistant.InvokeInternal - Replicating associations via MailboxAssistant for mailbox with ID {0}", objectId);
                ADUser aduser = adSession.FindADUserByObjectId(objectId);
                if (aduser == null)
                {
                    string text = string.Format("MailboxAssociationReplicationAssistant.InvokeInternal - Couldn't find AdUser with AdObjectId {0}.", objectId);
                    MailboxAssociationReplicationAssistant.Tracer.TraceDebug((long)this.GetHashCode(), text);
                    LocalAssociationStore.SaveMailboxSyncStatus(mailboxSession, new ExDateTime?(ExDateTime.Now.Add(MailboxAssociationReplicationAssistant.TimeToWaitForAdReplication)), null);
                    accessLayer.Logger.LogEvent(new SchemaBasedLogEvent <MailboxAssociationLogSchema.Error>
                    {
                        {
                            MailboxAssociationLogSchema.Error.Context,
                            "MailboxAssociationReplicationAssistant"
                        },
                        {
                            MailboxAssociationLogSchema.Error.Exception,
                            text
                        }
                    });
                    return;
                }
                if (aduser.RecipientTypeDetails != RecipientTypeDetails.GroupMailbox && aduser.RecipientTypeDetails != RecipientTypeDetails.UserMailbox)
                {
                    MailboxAssociationReplicationAssistant.Tracer.TraceDebug <Guid, string, string>((long)this.GetHashCode(), "Skipping mailbox with guid {0} and display name {1} since this is a {2} and not a GroupMailbox or UserMailbox", mailboxSession.MailboxGuid, mailboxSession.MailboxOwner.MailboxInfo.DisplayName, mailboxSession.MailboxOwner.RecipientTypeDetails.ToString());
                    return;
                }
                MailboxAssociationReplicationAssistant.Tracer.TraceDebug <string, string>((long)this.GetHashCode(), "MailboxAssociationReplicationAssistant.InvokeInternal - Master Mailbox: ExternalID {0}, LegDN {1}", aduser.ExternalDirectoryObjectId, aduser.LegacyExchangeDN);
                ICollection <IMailboxLocator> associationsToReplicate = MailboxAssociationReplicationAssistant.GetAssociationsToReplicate(invokeArgs.Parameters, adSession);
                if (associationsToReplicate == null)
                {
                    MailboxAssociationReplicationAssistant.Tracer.TraceDebug((long)this.GetHashCode(), "MailboxAssociationReplicationAssistant.InvokeInternal - No locators provided in RunNow parameters, replicating all out-of-sync associations");
                    this.ReplicateOutOfSyncAssociations(mailboxSession, aduser, adSession, accessLayer);
                    return;
                }
                MailboxAssociationReplicationAssistant.Tracer.TraceDebug((long)this.GetHashCode(), "MailboxAssociationReplicationAssistant.InvokeInternal - Found slave locators in RunNow parameters, replicating only provided associations");
                this.ReplicateAssociations(aduser, adSession, associationsToReplicate, accessLayer);
            });
        }