コード例 #1
0
 internal ADUser ResolveUser(ADObjectId id, out Exception ex)
 {
     if (id == null)
     {
         throw new ArgumentNullException("id");
     }
     return(TeamMailboxADUserResolver.Resolve(this.adSession, id, out ex));
 }
コード例 #2
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"));
        }