コード例 #1
0
        private void CallMailboxAssociationReplicationAssistant(ADUser groupMailbox)
        {
            Exception ex = null;

            try
            {
                ActiveManager        activeManagerInstance = ActiveManager.GetActiveManagerInstance();
                DatabaseLocationInfo serverForDatabase     = activeManagerInstance.GetServerForDatabase(groupMailbox.Database.ObjectGuid);
                base.WriteVerbose("Group mailbox database is on server {0}", new object[]
                {
                    serverForDatabase.ServerFqdn
                });
                using (AssistantsRpcClient assistantsRpcClient = new AssistantsRpcClient(serverForDatabase.ServerFqdn))
                {
                    assistantsRpcClient.StartWithParams("MailboxAssociationReplicationAssistant", groupMailbox.ExchangeGuid, groupMailbox.Database.ObjectGuid, string.Empty);
                }
                base.WriteVerbose("Started update of the user mailboxes for the new ExternalDirectoryObjectId", new object[0]);
            }
            catch (RpcException ex2)
            {
                ex = ex2;
            }
            catch (LocalizedException ex3)
            {
                ex = ex3;
            }
            if (ex != null)
            {
                base.WriteVerbose("Failed to call RPC to MailboxAssociationReplicationAssistant due the following exception: {0}", new object[]
                {
                    ex
                });
                this.WriteWarning(Strings.WarningUnableToUpdateUserMailboxes);
            }
        }
コード例 #2
0
 protected override void InternalProcessRecord()
 {
     TaskLogger.LogEnter();
     try
     {
         ADUser dataObject = this.DataObject;
         if (dataObject == null)
         {
             base.WriteError(new ObjectNotFoundException(Strings.MailboxAssociationMailboxNotFound), ExchangeErrorCategory.Client, this.DataObject);
         }
         else
         {
             int    num;
             string remoteServerForADUser = TaskHelper.GetRemoteServerForADUser(dataObject, new Task.TaskVerboseLoggingDelegate(base.CurrentTaskContext.CommandShell.WriteVerbose), out num);
             base.WriteVerbose(Strings.MailboxAssociationReplicationRpcRequest(dataObject.Id.ToString(), remoteServerForADUser));
             using (AssistantsRpcClient assistantsRpcClient = new AssistantsRpcClient(remoteServerForADUser))
             {
                 assistantsRpcClient.StartWithParams(StartMailboxAssociationReplication.MailboxAssociationReplicationAssistantName, dataObject.ExchangeGuid, dataObject.Database.ObjectGuid, string.Empty);
             }
         }
     }
     finally
     {
         TaskLogger.LogExit();
     }
 }
コード例 #3
0
        protected override void InternalProcessRecord()
        {
            TaskLogger.LogEnter();
            ELCTaskHelper.VerifyIsInConfigScopes(this.DataObject, base.SessionSettings, new Task.TaskErrorLoggingDelegate(base.WriteError));
            string fqdn = this.DataObject.Fqdn;
            AssistantsRpcClient assistantsRpcClient = new AssistantsRpcClient(fqdn);
            int num = 3;

            try
            {
IL_37:
                assistantsRpcClient.Stop("ElcAssistant");
            }
            catch (RpcException ex)
            {
                num--;
                if ((ex.ErrorCode == 1753 || ex.ErrorCode == 1727) && num > 0)
                {
                    goto IL_37;
                }
                base.WriteError(new TaskException(RpcUtility.MapRpcErrorCodeToMessage(ex.ErrorCode, fqdn)), ErrorCategory.InvalidOperation, null);
                goto IL_37;
            }
            TaskLogger.LogExit();
        }
コード例 #4
0
 public static void SyncFolder(MailboxSession mailboxSession, StoreObjectId folderId)
 {
     Util.ThrowOnNullArgument(mailboxSession, "mailboxSession");
     Util.ThrowOnNullArgument(folderId, "folderId");
     using (AssistantsRpcClient assistantsRpcClient = new AssistantsRpcClient(mailboxSession.MailboxOwner.MailboxInfo.Location.ServerFqdn))
     {
         try
         {
             assistantsRpcClient.StartWithParams("CalendarSyncAssistant", mailboxSession.MailboxOwner.MailboxInfo.MailboxGuid, mailboxSession.MailboxOwner.MailboxInfo.GetDatabaseGuid(), folderId.ToHexEntryId());
         }
         catch (RpcException arg)
         {
             ExTraceGlobals.SharingTracer.TraceDebug <IExchangePrincipal, StoreObjectId, RpcException>(0L, "{0}: SyncAssistantInvoker.SyncFolder for folder id {1} failed with exception {2}.", mailboxSession.MailboxOwner, folderId, arg);
         }
     }
 }
コード例 #5
0
        public bool Invoke(string command, IAssociationAdaptor masterAdaptor, params MailboxAssociation[] associations)
        {
            ArgumentValidator.ThrowIfNull("masterAdaptor", masterAdaptor);
            ADUser masterMailbox       = masterAdaptor.MasterLocator.FindAdUser();
            bool   isRpcCallSuccessful = false;

            GrayException.MapAndReportGrayExceptions(delegate()
            {
                try
                {
                    MailboxLocator[] array = associations.Select(new Func <MailboxAssociation, MailboxLocator>(masterAdaptor.GetSlaveMailboxLocator)).ToArray <MailboxLocator>();
                    this.logger.LogEvent(new SchemaBasedLogEvent <MailboxAssociationLogSchema.CommandExecution>
                    {
                        {
                            MailboxAssociationLogSchema.CommandExecution.Command,
                            command
                        },
                        {
                            MailboxAssociationLogSchema.CommandExecution.GroupMailbox,
                            masterAdaptor.MasterLocator
                        },
                        {
                            MailboxAssociationLogSchema.CommandExecution.UserMailboxes,
                            array
                        }
                    });
                    RpcAssociationReplicatorRunNowParameters rpcAssociationReplicatorRunNowParameters = new RpcAssociationReplicatorRunNowParameters
                    {
                        SlaveMailboxes = array
                    };
                    ReplicationAssistantInvoker.Tracer.TraceDebug <string, RpcAssociationReplicatorRunNowParameters>((long)this.GetHashCode(), "ReplicationAssistantInvoker::ReplicateAssociations. Calling RpcAssociationReplicator in '{0}' with parameter: '{1}'", this.targetServerFqdn, rpcAssociationReplicatorRunNowParameters);
                    using (AssistantsRpcClient assistantsRpcClient = new AssistantsRpcClient(this.targetServerFqdn))
                    {
                        assistantsRpcClient.StartWithParams("MailboxAssociationReplicationAssistant", masterMailbox.ExchangeGuid, masterMailbox.Database.ObjectGuid, rpcAssociationReplicatorRunNowParameters.ToString());
                    }
                    isRpcCallSuccessful = true;
                }
                catch (RpcException ex)
                {
                    this.LogError(Strings.RpcReplicationCallFailed(ex.ErrorCode));
                    masterAdaptor.AssociationStore.SaveMailboxAsOutOfSync();
                }
            });
            return(isRpcCallSuccessful);
        }
コード例 #6
0
        private void InternalProcessOneRequest(AssistantsRpcClient client, string serverName, Guid mailboxGuid, Guid mdbGuid)
        {
            int num = 3;

            try
            {
IL_02:
                client.StartWithParams("ElcAssistant", mailboxGuid, mdbGuid, this.GetElcParameters().ToString());
            }
            catch (RpcException ex)
            {
                num--;
                if ((ex.ErrorCode == 1753 || ex.ErrorCode == 1727) && num > 0)
                {
                    goto IL_02;
                }
                base.WriteError(new TaskException(RpcUtility.MapRpcErrorCodeToMessage(ex.ErrorCode, serverName)), ErrorCategory.InvalidOperation, null);
                goto IL_02;
            }
        }
コード例 #7
0
        private void InternalProcessOneMailbox(Guid mailboxGuid, Guid mdbGuid)
        {
            ExchangePrincipal exchangePrincipal = null;

            try
            {
                ADSessionSettings orgWideSessionSettings = base.OrgWideSessionSettings;
                if (VariantConfiguration.InvariantNoFlightingSnapshot.CmdletInfra.InactiveMailbox.Enabled)
                {
                    orgWideSessionSettings.IncludeInactiveMailbox = true;
                }
                exchangePrincipal = ExchangePrincipal.FromMailboxGuid(orgWideSessionSettings, mailboxGuid, null);
            }
            catch (ObjectNotFoundException exception)
            {
                base.WriteError(exception, ErrorCategory.InvalidArgument, this.Identity);
            }
            string serverFqdn          = exchangePrincipal.MailboxInfo.Location.ServerFqdn;
            AssistantsRpcClient client = new AssistantsRpcClient(serverFqdn);

            this.InternalProcessOneRequest(client, serverFqdn, mailboxGuid, mdbGuid);
            this.processed = true;
        }
コード例 #8
0
 protected override void InternalProcessRecord()
 {
     TaskLogger.LogEnter();
     try
     {
         ADUser aduser = this.DataObject as ADUser;
         if (aduser == null || aduser.RecipientTypeDetails != RecipientTypeDetails.PublicFolderMailbox)
         {
             base.WriteError(new ObjectNotFoundException(Strings.PublicFolderMailboxNotFound), ExchangeErrorCategory.Client, aduser);
         }
         ExchangePrincipal exchangePrincipal = ExchangePrincipal.FromADUser(base.SessionSettings, aduser);
         string            serverFqdn        = exchangePrincipal.MailboxInfo.Location.ServerFqdn;
         if (this.InvokeSynchronizer)
         {
             TenantPublicFolderConfiguration value = TenantPublicFolderConfigurationCache.Instance.GetValue(aduser.OrganizationId);
             Organization orgContainer             = this.ConfigurationSession.GetOrgContainer();
             if (orgContainer.DefaultPublicFolderMailbox.HierarchyMailboxGuid != value.GetHierarchyMailboxInformation().HierarchyMailboxGuid || value.GetLocalMailboxRecipient(aduser.ExchangeGuid) == null)
             {
                 TenantPublicFolderConfigurationCache.Instance.RemoveValue(aduser.OrganizationId);
             }
             if (aduser.ExchangeGuid == value.GetHierarchyMailboxInformation().HierarchyMailboxGuid)
             {
                 base.WriteError(new TaskArgumentException(Strings.ErrorSecondaryMailboxIdRequired), ExchangeErrorCategory.Client, exchangePrincipal);
             }
             if (this.FullSync)
             {
                 using (PublicFolderSession publicFolderSession = PublicFolderSession.OpenAsAdmin(this.DataObject.OrganizationId, null, aduser.ExchangeGuid, null, CultureInfo.CurrentCulture, "Client=Management;Action=UpdatePublicFolderMailbox", null))
                 {
                     using (Folder folder = Folder.Bind(publicFolderSession, publicFolderSession.GetTombstonesRootFolderId()))
                     {
                         using (UserConfiguration configuration = UserConfiguration.GetConfiguration(folder, new UserConfigurationName("PublicFolderSyncInfo", ConfigurationNameKind.Name), UserConfigurationTypes.Dictionary))
                         {
                             IDictionary dictionary = configuration.GetDictionary();
                             dictionary["SyncState"] = null;
                             configuration.Save();
                         }
                     }
                 }
             }
             PublicFolderSyncJobState publicFolderSyncJobState = PublicFolderSyncJobRpc.StartSyncHierarchy(exchangePrincipal, this.ReconcileFolders);
             if (!this.SuppressStatus)
             {
                 base.WriteObject(new UpdatePublicFolderMailboxResult(Strings.StatusMessageStartUpdatePublicFolderMailbox(this.Identity.ToString())));
                 int num = 0;
                 while (publicFolderSyncJobState.JobStatus != PublicFolderSyncJobState.Status.Completed && publicFolderSyncJobState.LastError == null && num++ < UpdatePublicFolderMailbox.timeToWaitInMilliseconds / UpdatePublicFolderMailbox.QueryIntervalInMilliseconds)
                 {
                     base.WriteObject(new UpdatePublicFolderMailboxResult(Strings.StatusMessageUpdatePublicFolderMailboxUnderProgress(publicFolderSyncJobState.JobStatus.ToString())));
                     Thread.Sleep(UpdatePublicFolderMailbox.QueryIntervalInMilliseconds);
                     publicFolderSyncJobState = PublicFolderSyncJobRpc.QueryStatusSyncHierarchy(exchangePrincipal);
                 }
                 if (publicFolderSyncJobState.LastError != null)
                 {
                     base.WriteError(publicFolderSyncJobState.LastError, ExchangeErrorCategory.ServerOperation, publicFolderSyncJobState);
                 }
                 if (publicFolderSyncJobState.JobStatus == PublicFolderSyncJobState.Status.Completed)
                 {
                     base.WriteObject(new UpdatePublicFolderMailboxResult(Strings.StatusMessageUpdatePublicFolderMailboxCompleted));
                 }
                 else
                 {
                     base.WriteObject(new UpdatePublicFolderMailboxResult(Strings.StatusMessageSynchronizerRunningInBackground));
                 }
             }
         }
         else if (aduser.ExchangeGuid != Guid.Empty)
         {
             MailboxDatabase mailboxDatabase = base.GlobalConfigSession.Read <MailboxDatabase>(aduser.Database);
             if (mailboxDatabase == null)
             {
                 base.WriteError(new TaskArgumentException(Strings.ElcMdbNotFound(this.Identity.ToString())), ExchangeErrorCategory.Client, null);
             }
             this.EnsureMailboxExistsOnDatabase(aduser.ExchangeGuid);
             AssistantsRpcClient assistantsRpcClient = new AssistantsRpcClient(serverFqdn);
             try
             {
                 assistantsRpcClient.Start("PublicFolderAssistant", aduser.ExchangeGuid, mailboxDatabase.Guid);
             }
             catch (RpcException ex)
             {
                 base.WriteError(new TaskException(RpcUtility.MapRpcErrorCodeToMessage(ex.ErrorCode, serverFqdn)), ExchangeErrorCategory.Client, null);
             }
         }
     }
     finally
     {
         TaskLogger.LogExit();
     }
 }
コード例 #9
0
        private void TryCallE15()
        {
            ADUser[] array = null;
            if (OABVariantConfigurationSettings.IsLinkedOABGenMailboxesEnabled)
            {
                ADObjectId generatingMailbox = this.DataObject.GeneratingMailbox;
                if (generatingMailbox != null)
                {
                    ADUser aduser = (ADUser)base.GetDataObject <ADUser>(new MailboxIdParameter(generatingMailbox), base.TenantGlobalCatalogSession, null, new LocalizedString?(Strings.ErrorMailboxAddressNotFound(generatingMailbox.ToString())), new LocalizedString?(Strings.ErrorMailboxAddressNotUnique(generatingMailbox.ToString())));
                    array = new ADUser[]
                    {
                        aduser
                    };
                }
            }
            if (array == null)
            {
                array = OrganizationMailbox.FindByOrganizationId(this.DataObject.OrganizationId, OrganizationCapability.OABGen);
                if (array.Length == 0)
                {
                    if (this.ownerServer != null && this.ownerServer.VersionNumber >= Server.E15MinVersion)
                    {
                        base.WriteError(new LocalizedException(Strings.ErrorOabGenFailedSinceNoOrgMbxFound(this.DataObject.Identity.ToString())), ErrorCategory.ObjectNotFound, this.Identity);
                    }
                    return;
                }
            }
            bool flag = false;

            foreach (ADUser aduser2 in array)
            {
                string activeServerFqdn = OrganizationMailbox.GetActiveServerFqdn(aduser2.Id);
                string text             = null;
                try
                {
                    OABGeneratorAssistantRunNowParameters oabgeneratorAssistantRunNowParameters = new OABGeneratorAssistantRunNowParameters
                    {
                        PartitionId = this.DataObject.Id.GetPartitionId(),
                        ObjectGuid  = this.DataObject.Id.ObjectGuid,
                        Description = "from Update-OAB on Server:" + Environment.MachineName
                    };
                    AssistantsRpcClient assistantsRpcClient = new AssistantsRpcClient(activeServerFqdn);
                    assistantsRpcClient.StartWithParams("OABGeneratorAssistant", aduser2.ExchangeGuid, aduser2.Database.ObjectGuid, oabgeneratorAssistantRunNowParameters.ToString());
                    flag = true;
                }
                catch (RpcException ex)
                {
                    text = RpcUtility.MapRpcErrorCodeToMessage(ex.ErrorCode, activeServerFqdn);
                }
                catch (COMException ex2)
                {
                    text = ex2.Message;
                }
                if (text != null)
                {
                    if (array.Length == 1)
                    {
                        base.WriteError(new LocalizedException(Strings.ErrorOabGenFailed(this.DataObject.Identity.ToString(), activeServerFqdn, text)), ErrorCategory.InvalidResult, this.Identity);
                    }
                    else
                    {
                        this.WriteWarning(Strings.WarningOabGenFailed(this.DataObject.Identity.ToString(), aduser2.Identity.ToString(), activeServerFqdn, text));
                    }
                }
            }
            if (array.Length > 1 && !flag)
            {
                base.WriteError(new LocalizedException(Strings.ErrorOabGenFailedForAllOrgMailboxes(this.DataObject.Identity.ToString())), ErrorCategory.InvalidResult, this.Identity);
            }
        }