Esempio n. 1
0
 protected override void InternalProcessRecord()
 {
     foreach (KeyValuePair <ADUser, ExchangePrincipal> keyValuePair in base.TMPrincipals)
     {
         ADUser            key   = keyValuePair.Key;
         ExchangePrincipal value = keyValuePair.Value;
         this.Target = new TeamMailboxDiagnosticsBase.TargetType?(this.Target ?? TeamMailboxDiagnosticsBase.TargetType.All);
         if (this.Target == TeamMailboxDiagnosticsBase.TargetType.Document || this.Target == TeamMailboxDiagnosticsBase.TargetType.All)
         {
             EnqueueResult enqueueResult = RpcClientWrapper.EnqueueTeamMailboxSyncRequest((!string.IsNullOrEmpty(this.Server)) ? this.Server : value.MailboxInfo.Location.ServerFqdn, value.MailboxInfo.MailboxGuid, QueueType.TeamMailboxDocumentSync, key.OrganizationId, "UpdateTMCMD_" + base.ExecutingUserIdentityName, base.DomainController, this.FullSync ? SyncOption.FullSync : SyncOption.Default);
             enqueueResult.Type = QueueType.TeamMailboxDocumentSync;
             base.WriteObject(enqueueResult);
         }
         if (this.Target == TeamMailboxDiagnosticsBase.TargetType.Membership || this.Target == TeamMailboxDiagnosticsBase.TargetType.All)
         {
             EnqueueResult enqueueResult2 = RpcClientWrapper.EnqueueTeamMailboxSyncRequest((!string.IsNullOrEmpty(this.Server)) ? this.Server : value.MailboxInfo.Location.ServerFqdn, value.MailboxInfo.MailboxGuid, QueueType.TeamMailboxMembershipSync, key.OrganizationId, "UpdateTMCMD_" + base.ExecutingUserIdentityName, base.DomainController, this.FullSync ? SyncOption.FullSync : SyncOption.Default);
             enqueueResult2.Type = QueueType.TeamMailboxMembershipSync;
             base.WriteObject(enqueueResult2);
         }
         if (this.Target == TeamMailboxDiagnosticsBase.TargetType.Maintenance || this.Target == TeamMailboxDiagnosticsBase.TargetType.All)
         {
             EnqueueResult enqueueResult3 = RpcClientWrapper.EnqueueTeamMailboxSyncRequest((!string.IsNullOrEmpty(this.Server)) ? this.Server : value.MailboxInfo.Location.ServerFqdn, value.MailboxInfo.MailboxGuid, QueueType.TeamMailboxMaintenanceSync, key.OrganizationId, "UpdateTMCMD_" + base.ExecutingUserIdentityName, base.DomainController, this.FullSync ? SyncOption.FullSync : SyncOption.Default);
             enqueueResult3.Type = QueueType.TeamMailboxMaintenanceSync;
             base.WriteObject(enqueueResult3);
         }
     }
 }
        // Token: 0x06001503 RID: 5379 RVA: 0x0007859C File Offset: 0x0007679C
        private static void EnqueueTeamMailboxSyncRequest(MailboxSession session, QueueType queueType, LoggingContext loggingContext)
        {
            string text = "Undefined";

            switch (queueType)
            {
            case QueueType.TeamMailboxDocumentSync:
                text = "document sync";
                break;

            case QueueType.TeamMailboxMembershipSync:
                text = "membership sync";
                break;

            case QueueType.TeamMailboxMaintenanceSync:
                text = "maintenance sync";
                break;
            }
            EnqueueResult enqueueResult = RpcClientWrapper.EnqueueTeamMailboxSyncRequest(session.MailboxOwner.MailboxInfo.Location.ServerFqdn, session.MailboxOwner.MailboxInfo.MailboxGuid, queueType, session.MailboxOwner.MailboxInfo.OrganizationId, "Site Mailbox Assistant", null, SyncOption.Default);

            if (enqueueResult.Result == EnqueueResultType.Successful)
            {
                ProtocolLog.LogInformation(ProtocolLog.Component.Assistant, loggingContext, string.Format("Successfully triggered {0} for site mailbox:{1}", text, session.MailboxOwner.MailboxInfo.PrimarySmtpAddress.ToString()));
                return;
            }
            if (enqueueResult.Result == EnqueueResultType.AlreadyPending)
            {
                ProtocolLog.LogInformation(ProtocolLog.Component.Assistant, loggingContext, string.Format("Skipped pending {0} for site mailbox:{1}. Detail:{2}", text, session.MailboxOwner.MailboxInfo.PrimarySmtpAddress.ToString(), enqueueResult.ResultDetail));
                return;
            }
            if (enqueueResult.Result == EnqueueResultType.RequestThrottled)
            {
                ProtocolLog.LogInformation(ProtocolLog.Component.Assistant, loggingContext, string.Format("Skipped throttled {0} for site mailbox:{1}. Detail:{2}", text, session.MailboxOwner.MailboxInfo.PrimarySmtpAddress.ToString(), enqueueResult.ResultDetail));
                return;
            }
            if (enqueueResult.Result == EnqueueResultType.UnlinkedTeamMailbox || enqueueResult.Result == EnqueueResultType.PendingDeleteTeamMailbox || enqueueResult.Result == EnqueueResultType.ClosedTeamMailbox || enqueueResult.Result == EnqueueResultType.NonexistentTeamMailbox)
            {
                ProtocolLog.LogInformation(ProtocolLog.Component.Assistant, loggingContext, string.Format("Skipped {0} for site mailbox:{1}. Detail:{2}", text, session.MailboxOwner.MailboxInfo.PrimarySmtpAddress.ToString(), enqueueResult.ResultDetail));
                return;
            }
            ProtocolLog.LogError(ProtocolLog.Component.Assistant, loggingContext, string.Format("Failed to trigger {0} for site mailbox:{1}. Error:{2}; Detail:{3}", new object[]
            {
                text,
                session.MailboxOwner.MailboxInfo.PrimarySmtpAddress.ToString(),
                enqueueResult.Result,
                enqueueResult.ResultDetail
            }), new OperationCanceledException());
        }
Esempio n. 3
0
        protected override void InternalProcessRecord()
        {
            ADUser      dataObject  = this.DataObject;
            TeamMailbox teamMailbox = TeamMailbox.FromDataObject(dataObject);

            this.teamMailboxHelper = new TeamMailboxHelper(teamMailbox, base.ExchangeRunspaceConfig.ExecutingUser, base.ExchangeRunspaceConfig.ExecutingUserOrganizationId, (IRecipientSession)base.DataSession, new TeamMailboxGetDataObject <ADUser>(base.GetDataObject <ADUser>));
            TeamMailboxMembershipHelper teamMailboxMembershipHelper = new TeamMailboxMembershipHelper(teamMailbox, (IRecipientSession)base.DataSession);
            Exception ex     = null;
            ADUser    aduser = TeamMailboxADUserResolver.Resolve((IRecipientSession)base.DataSession, this.executingUserId, out ex);

            if (aduser == null)
            {
                base.WriteError(new RecipientTaskException(Strings.ErrorExecutingUserIsNull), ExchangeErrorCategory.Client, null);
            }
            if (base.Fields.IsModified("DisplayName"))
            {
                teamMailbox.DisplayName = this.DisplayName;
            }
            teamMailbox.SetPolicy(this.provisioningPolicy);
            base.WriteVerbose(Strings.SiteMailboxPolicySet(this.provisioningPolicy.ToString()));
            teamMailbox.SetMyRole(this.executingUserId);
            Uri sharePointUrl = this.SharePointUrl;
            SharePointMemberShip sharePointMemberShip = SharePointMemberShip.Others;
            Uri  webCollectionUrl = null;
            Guid empty            = Guid.Empty;

            if (base.Fields.IsModified("SharePointUrl") && !base.Fields.IsModified("Force"))
            {
                try
                {
                    TeamMailboxHelper.CheckSharePointSite(SmtpAddress.Empty, ref sharePointUrl, base.ExchangeRunspaceConfig.ExecutingUser, base.ExchangeRunspaceConfig.ExecutingUserOrganizationId, aduser, out sharePointMemberShip, out webCollectionUrl, out empty);
                }
                catch (RecipientTaskException exception)
                {
                    base.WriteError(exception, ExchangeErrorCategory.Client, null);
                }
            }
            teamMailbox.SharePointUrl = sharePointUrl;
            teamMailbox.SetSharePointSiteInfo(webCollectionUrl, empty);
            teamMailbox.SharePointLinkedBy = this.executingUserId;
            List <ADObjectId>  list          = new List <ADObjectId>();
            List <ADObjectId>  list2         = new List <ADObjectId>();
            IList <ADObjectId> list3         = null;
            IList <ADObjectId> usersToRemove = null;

            if (TeamMailboxMembershipHelper.IsUserQualifiedType(aduser))
            {
                if (sharePointMemberShip == SharePointMemberShip.Owner)
                {
                    list.Add(this.executingUserId);
                    teamMailboxMembershipHelper.UpdateTeamMailboxUserList(teamMailbox.Owners, list, out list3, out usersToRemove);
                    teamMailboxMembershipHelper.UpdateTeamMailboxUserList(teamMailbox.OwnersAndMembers, list, out list3, out usersToRemove);
                }
                else if (sharePointMemberShip == SharePointMemberShip.Member)
                {
                    list2.Add(this.executingUserId);
                    teamMailboxMembershipHelper.UpdateTeamMailboxUserList(teamMailbox.OwnersAndMembers, list2, out list3, out usersToRemove);
                }
            }
            Exception ex2 = null;

            try
            {
                teamMailboxMembershipHelper.SetTeamMailboxUserPermissions(list3, usersToRemove, new SecurityIdentifier[]
                {
                    WellKnownSids.SiteMailboxGrantedAccessMembers
                }, false);
                if (list3 != null)
                {
                    base.WriteVerbose(Strings.SiteMailboxCreatorSet(list3[0].ToString()));
                }
            }
            catch (OverflowException ex3)
            {
                ex2 = ex3;
            }
            catch (COMException ex4)
            {
                ex2 = ex4;
            }
            catch (UnauthorizedAccessException ex5)
            {
                ex2 = ex5;
            }
            catch (TransientException ex6)
            {
                ex2 = ex6;
            }
            catch (DataSourceOperationException ex7)
            {
                ex2 = ex7;
            }
            if (ex2 != null)
            {
                base.WriteError(new RecipientTaskException(Strings.ErrorSetTeamMailboxUserPermissions(teamMailbox.DisplayName, ex2.Message)), ExchangeErrorCategory.Client, null);
            }
            base.InternalProcessRecord();
            if (base.Fields.IsModified("SharePointUrl") && !base.Fields.IsModified("Force"))
            {
                try
                {
                    this.teamMailboxHelper.LinkSharePointSite(sharePointUrl, true, false);
                    base.WriteVerbose(Strings.SiteMailboxLinkedToSharePointSite(sharePointUrl.AbsoluteUri));
                }
                catch (RecipientTaskException exception2)
                {
                    base.DataSession.Delete(this.DataObject);
                    base.WriteError(exception2, ExchangeErrorCategory.Client, null);
                }
            }
            IList <Exception> list4;

            teamMailboxMembershipHelper.SetShowInMyClient(list3, usersToRemove, out list4);
            foreach (Exception ex8 in list4)
            {
                this.WriteWarning(Strings.ErrorTeamMailboxResolveUser(ex8.Message));
            }
            EnqueueResult enqueueResult = EnqueueResult.Success;

            if (this.databaseLocationInfo != null)
            {
                int num = 0;
                for (;;)
                {
                    base.WriteVerbose(new LocalizedString(string.Format("Trying to send membership sync request to server {0} for MailboxGuid {1} using domain controller {2}", this.databaseLocationInfo.ServerFqdn, dataObject.ExchangeGuid, this.lastUsedDc)));
                    enqueueResult = RpcClientWrapper.EnqueueTeamMailboxSyncRequest(this.databaseLocationInfo.ServerFqdn, dataObject.ExchangeGuid, QueueType.TeamMailboxMembershipSync, base.CurrentOrganizationId, "NewTMCMD_" + base.ExecutingUserIdentityName, this.lastUsedDc, SyncOption.Default);
                    base.WriteVerbose(new LocalizedString(string.Format("The membership sync result is {0}", enqueueResult.Result)));
                    if (enqueueResult.Result == EnqueueResultType.Successful)
                    {
                        goto IL_409;
                    }
                    if (num > 12)
                    {
                        break;
                    }
                    Thread.Sleep(5000);
                    num++;
                }
                this.WriteWarning(Strings.ErrorTeamMailboxEnqueueMembershipSyncEvent(enqueueResult.ResultDetail));
                goto IL_414;
IL_409:
                base.WriteVerbose(Strings.SiteMailboxMembershipSyncEventEnqueued);
IL_414:
                enqueueResult = RpcClientWrapper.EnqueueTeamMailboxSyncRequest(this.databaseLocationInfo.ServerFqdn, dataObject.ExchangeGuid, QueueType.TeamMailboxDocumentSync, base.CurrentOrganizationId, "NewTMCMD_" + base.ExecutingUserIdentityName, this.lastUsedDc, SyncOption.Default);
                base.WriteVerbose(new LocalizedString(string.Format("Document sync request to server {0} for MailboxGuid {1} using domain controller {2}. The result is: {3}", new object[]
                {
                    this.databaseLocationInfo.ServerFqdn,
                    dataObject.ExchangeGuid,
                    this.lastUsedDc,
                    enqueueResult.ResultDetail
                })));
                return;
            }
            this.WriteWarning(Strings.ErrorTeamMailboxEnqueueMembershipSyncEvent("No database location information available"));
        }