閱讀英文

共用方式為


在 SharePoint Server 中設定網站信箱

 

**適用版本:**Exchange Server, SharePoint Server 2013, SharePoint Server 2016

**上次修改主題的時間:**2017-09-19

**摘要:**設定小組電子郵件的 Exchange Server、SharePoint Server 2016 和 SharePoint Server 2013,方法為使用 Site Mailboxes 功能。

本文描述如何設定 SharePoint Server 及 Exchange Server 中的網站信箱。網站信箱功能可在網站上提供小組電子郵件給 SharePoint Server 使用者。網站信箱也在 Microsoft Outlook 中提供 SharePoint 文件庫連結,讓使用者能夠和其他共同合作專案的小組成員共用檔案及電子郵件訊息。

開始之前

開始此作業之前,請先檢閱下列必要條件的相關資訊:

  • 網站信箱需要 Exchange Server 2016 或 Exchange Server 2013。

  • 必須從 SharePoint 伺服器解除安裝所有的舊版 Exchange Web 服務 (EWS)。

    注意

    您可能需要判斷是否安裝了舊版的 EWS。如果是,請執行以下參考的 Check-SiteMailboxConfig 指令碼。

  • 網站信箱功能需要在伺服器陣列中設定使用者設定檔同步處理。如需設定使用者設定檔同步處理的資訊,請參閱規劃使用者設定檔及身分識別管理 SharePoint Server 中的使用者設定檔同步處理

  • 網站信箱功能需要在伺服器陣列中設定應用程式管理服務應用程式。如需設定應用程式管理服務應用程式的相關資訊,請參閱 New-SPAppManagementServiceApplication

  • 對於在支援伺服器對伺服器驗證及應用程式驗證的案例中所部署的 Web 應用程式,預設區域必須設定安全通訊端層 (SSL)。執行 SharePoint Server 的電腦必須設定 SSL,這是設定網站信箱的必要條件。如需詳細資訊,請參閱在 SharePoint 2013 中建立宣告式 Web 應用程式,並遵循建立 SSL 網站集合及伺服器憑證的步驟。

    注意

    可能需要將 Exchange Server SSL 憑證從 Exchange Server 匯入 SharePoint Server,並且從 SharePoint Server 匯入 Exchange Server。API 端點不信任憑證時才需要這麼做 (例如實驗室環境下的 Self-SSL 憑證)。
    若要將不受信任的 SSL 憑證匯入新的伺服器:

    • 開啟 Internet Explorer 並瀏覽至 Outlook Web App (若部署在 SharePoint Server 上) 或 SSL SharePoint 網站 (若部署在 Exchange Server 上):https://<ExServerName>/owa 或 https://<SP_FQDN>。

    • 按一下 [繼續瀏覽網站] 接受信任此憑證。

    • 按一下 Internet Explorer 中網址列旁的 [憑證錯誤] 資訊,然後按一下 [檢視憑證]。

    • 選取 [安裝憑證],然後選取 [將所有憑證放入以下的存放區]。

    • 選取核取方塊以顯示實體存放區。

    • 安裝憑證至 [信任的根憑證授權] > [本機電腦]。

  • 您必須是 SharePoint 及 Exchange Server 管理員群組,且具有包含使用者信箱的可作業 Exchange Server,才能執行這些程序。

  • SharePoint 備份解決方案並未納入 Exchange 網站信箱。Exchange 系統管理員務必適時對網站信箱進行備份。

  • 從網站信箱存取 SharePoint 文件庫中之檔案的使用者,必須在瀏覽器中將文件庫設定為信任的網站,否則會出現警告詢問使用者是否要信任此網站。

設定 SharePoint Server 中網站信箱的 SharePoint

設定網站信箱的第一個步驟是在 SharePoint Server 伺服器陣列中的每部 Web 和應用程式伺服器上安裝 Exchange Server Web Services API。

在 SharePoint Server 上安裝 Exchange Web Services API

  1. Microsoft 下載中心 (https://www.microsoft.com/en-us/download/details.aspx?id=35371) 下載 EWSManagedAPI.msi,並將其儲存至每部 web 和應用程式伺服器上的資料夾。

  2. 以管理員身分開啟命令視窗並瀏覽至您儲存 EWSManagedAPI.msi 所在的資料夾。

  3. 執行下列命令:

    msiexec /I EwsManagedApi.msi addlocal="ExchangeWebServicesApi_Feature,ExchangeWebServicesApi_Gac"
    
  4. 輸入 IISReset以從命令列重設 IIS。

在 SharePoint Server 上建立 OAuth 信任及服務權限

下一個步驟是複製下列兩個指令碼。第一個指令碼應儲存為 Set-SiteMailboxConfig.ps1,而第二個指令碼應儲存為 Check-SiteMailboxConfig.ps1。

Set-SiteMailboxConfig.ps1:

# .SYNOPSIS
# Set-SiteMailboxConfig helps configure Site Mailboxes for a SharePoint farm
# .DESCRIPTION
# Establishes trust with an Exchange Server, sets Site Mailbox settings and enables Site Mailboxes for a farm.
# .PARAMETER ExchangeSiteMailboxDomain
# The FQDN of the Exchange Organization where Site Mailboxes will be created
# .PARAMETER ExchangeAutodiscoverDomain
# [Optional] The FQDN of an Exchange Autodiscover Virtual Directory
# .PARAMETER WebApplicationUrl
# [Optional] The URL of a specific web application to configure. If not specified all Web Applications will be configured
# .PARAMETER Force
# [Optional] Indicate that the script should ignore any configuration issues and enable Site Mailboxes anyway

Param
(
   [Parameter(Mandatory=$true)]
   [ValidateNotNullOrEmpty()]   
   [string]$ExchangeSiteMailboxDomain,
   [Parameter(Mandatory=$false)]
   [ValidateNotNullOrEmpty()]   
   [string]$ExchangeAutodiscoverDomain,
   [Parameter(Mandatory=$false)]
   [ValidateNotNullOrEmpty()]   
   [string]$WebApplicationUrl,
   [Parameter(Mandatory=$false)]
   [switch]$Force
)

$script:currentDirectory = Split-Path $MyInvocation.MyCommand.Path

if($WebApplicationUrl -ne $NULL -and $WebApplicationUrl -ne "")
{
    $webapps = Get-SPWebApplication $WebApplicationUrl
}
else
{
    $webapps = Get-SPWebApplication
}

if($webapps -eq $NULL)
{
    if($WebApplicationUrl -ne $NULL)
    {
        Write-Warning "No Web Application Found at $($WebApplicationUrl). Please create a web application and re-run Set-SiteMailboxConfig"
    }
    else
    {
        Write-Warning "No Web Applications Found. Please create a web application and re-run Set-SiteMailboxConfig"
    }
    
    return
}

$rootWeb = $NULL

foreach($webapp in $webapps)
{
    if($rootWeb -eq $NULL)
    {
        $rootWeb = Get-SPWeb $webApp.Url -EA SilentlyContinue
    }
}

if($rootWeb -eq $NULL)
{
    Write-Warning "Unable to find a root site collection. Please create a root site collection on a web application and re-run Set-SiteMailboxConfig"
    return
}

$exchangeServer = $ExchangeAutodiscoverDomain

if($exchangeServer -eq $NULL -or $exchangeServer -eq "")
{
    $exchangeServer = "autodiscover.$($ExchangeSiteMailboxDomain)"
}

Write-Host "Establishing Trust with Exchange Server: $($exchangeServer)"

$metadataEndpoint = "https://$($exchangeServer)/autodiscover/metadata/json/1"

$exchange = Get-SPTrustedSecurityTokenIssuer | Where-Object { $_.MetadataEndpoint -eq $metadataEndpoint }

if($exchange -eq $NULL)  
{
    $exchange = New-SPTrustedSecurityTokenIssuer -Name $exchangeServer -MetadataEndPoint $metadataEndpoint
}

if($exchange -eq $NULL)
{
    Write-Warning "Unable to establish trust with Exchange Server $($exchangeServer). Ensure that $($metadataEndpoint) is accessible."

    if($ExchangeAutodiscoverDomain -eq $NULL -or $ExchangeAutodiscoverDomain -eq "")
    {
        Write-Warning "If $($metadataEndpoint) does not exist you may specify an alternate FQDN using ExchangeAutodiscoverDomain."
    }
    return
}

Write-Host "Granting Permissions to Exchange Server: $($exchangeServer)"
$appPrincipal = Get-SPAppPrincipal -Site $rootWeb.Url -NameIdentifier $exchange.NameId
Set-SPAppPrincipalPermission -AppPrincipal $appPrincipal -Site $rootWeb -Scope SiteSubscription -Right FullControl -EnableAppOnlyPolicy

Write-Host
Write-Host

Write-Host "Verifying Site Mailbox Configuration"
$warnings = & $script:currentDirectory\Check-SiteMailboxConfig.ps1 -ReturnWarningState

if($warnings -and -not $Force)
{
    Write-Warning "Pre-requisites not satisfied. Stopping Set-SiteMailboxConfig. Use -Force to override"
    return
}
elseif($warnings)
{
    Write-Warning "Pre-requisites not satisfied. -Force used to override"
}

foreach($webapp in $webapps)
{
    Write-Host "Configuring Web Application: $($webapp.Url)"
    Write-Host "Setting Exchange Site Mailbox Domain to $($ExchangeSiteMailboxDomain)"
    $webapp.Properties["ExchangeTeamMailboxDomain"] = $ExchangeSiteMailboxDomain
        
    if($ExchangeAutodiscoverDomain -ne $NULL -and $ExchangeAutodiscoverDomain -ne "")
    {
        Write-Host "Setting Exchange Autodiscover Domain to $($ExchangeAutodiscoverDomain)"
        $webapp.Properties["ExchangeAutodiscoverDomain"] = $ExchangeAutodiscoverDomain;
    }

    $webapp.Update()
}

$feature = Get-SPFeature CollaborationMailboxFarm -Farm -ErrorAction Ignore

if($feature -eq $NULL)
{
    Write-Host "Enabling Site Mailboxes for Farm"
    Enable-SPFeature CollaborationMailboxFarm
}
else
{
    Write-Host "Site Mailboxes already enabled for Farm"
}

Check-SiteMailboxConfig.ps1:

Param
(
   [Parameter(Mandatory=$false)]
   [ValidateNotNullOrEmpty()]   
   [switch]$ReturnWarningState
)

Add-PSSnapin Microsoft.SharePoint.Powershell

$anyWarnings = $false

Write-Host "Step 1: Checking for Exchange Web Services"

try
{
    $assm = [System.Reflection.Assembly]::Load("Microsoft.Exchange.WebServices, Version=15.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35")
    if($assm.GlobalAssemblyCache)
    {
        Write-Host -Foreground Green "Found Exchange Web Services in Global Assembly Cache"
        Write-Host "Exchange Web Services Version: $([System.Diagnostics.FileVersionInfo]::GetVersionInfo($assm.Location).FileVersion)"
    }
    else
    {
        Write-Warning "Unable to find Exchange Web Services in Global Assembly Cache"
        $anyWarnings = $true
    }
}
catch
{
    Write-Warning "Unable to find Exchange Web Services in Global Assembly Cache"
    $anyWarnings = $true
}


Write-Host
Write-Host

Write-Host "Step 2: Checking for https web application"

$webapps = Get-SPWebApplication -EA SilentlyContinue

$rootWeb = $NULL

if($webapps -ne $NULL)
{
    $sslWebAppExists = $false
    foreach($webapp in $webapps)
    {
        if($rootWeb -eq $NULL)
        {
            $rootWeb = Get-SPWeb $webApp.Url -EA SilentlyContinue
        }

        if(-not $webapp.Url.StartsWith("https://"))
        {
            Write-Warning "Web Application at $($webapp.Url) does not use HTTPS. Site Mailboxes will not work on this Web Application."
        }
        else
        {
            $sslWebAppExists = $true
            Write-Host -Foreground Green "Found Web Application at $($webapp.Url) that uses HTTPS"
        }
    }

    if(-not $sslWebAppExists)
    {
        Write-Warning "At least one Web Application must be configured for HTTPS in the default zone."
        $anyWarnings = $true
    }
}
else
{
    Write-Warning "No Web Applications Found. Please create a web application and re-run Check-SiteMailboxConfig"
    $anyWarnings = $true
    if($ReturnWarningState)
    {
        return $anyWarnings
    }
    return;
}

if($rootWeb -eq $NULL)
{
    Write-Warning "Unable to find any Sites. Please create a root site collection on a web application and re-run Check-SiteMailboxConfig"
    $anyWarnings = $true
    if($ReturnWarningState)
    {
        return $anyWarnings
    }
    return;
}

# Get App Permissions Management Objects
$appPrincipalManager = [Microsoft.SharePoint.SPAppPrincipalManager]::GetManager($rootWeb)
$appPrincipalPermissionsManager = New-Object -TypeName Microsoft.SharePoint.SPAppPrincipalPermissionsManager -ArgumentList $rootWeb        

Write-Host
Write-Host
Write-Host "Step 3: Checking for trusted Exchange Servers"

$trustedIssuers = Get-SPTrustedSecurityTokenIssuer
$trustedIssuerHosts = @()

if($trustedIssuers -ne $NULL)
{
    $foundTrustedIssuer = $false
    foreach($trustedIssuer in $trustedIssuers)
    {
        if($trustedIssuer.RegisteredIssuerName.StartsWith("00000002-0000-0ff1-ce00-000000000000@"))
        {
            if($trustedIssuer.IsSelfIssuer)
            {
                $foundTrustedIssuer = $true

                $uri = New-Object -TypeName System.Uri -ArgumentList $trustedIssuer.MetadataEndPoint
                
                Write-Host -Foreground Green "Found trusted Exchange Server at $($uri.Host)"
                $appPrincipalName = [Microsoft.SharePoint.SPAppPrincipalName]::CreateFromNameIdentifier($trustedIssuer.RegisteredIssuerName)
                $appPrincipal = $appPrincipalManager.LookupAppPrincipal([Microsoft.SharePoint.SPAppPrincipalIdentityProvider]::External, $appPrincipalName);
                


                if($appPrincipal -ne $NULL)
                {
                    $isValidAppPrincipal = $true;

                    if($appPrincipalPermissionsManager.GetAppPrincipalSiteSubscriptionContentPermission($appPrincipal) -eq [Microsoft.SharePoint.SPAppPrincipalPermissionKind]::FullControl)
                    {
                        Write-Host -Foreground Green "Exchange Server at $($uri.Host) has Full Control permissions"
                        
                    }
                    else
                    {
                        Write-Warning "Exchange Server at $($uri.Host) does not have Full Control permissions"
                        $isValidAppPrincipal = $false;
                        $anyWarnings = $true
                    }

                    if($appPrincipalPermissionsManager.IsAppOnlyPolicyAllowed($appPrincipal))
                    {
                        Write-Host -Foreground Green "Exchange Server at $($uri.Host) has App Only Permissions"
                    }
                    else
                    {
                        Write-Warning "Exchange Server at $($uri.Host) does not have App Only Permissions"
                        $isValidAppPrincipal = $false;
                        $anyWarnings = $true
                    }
                    
                    if($isValidAppPrincipal)
                    {
                        $trustedIssuerHosts += $uri.Host
                    }

                }
                else
                {
                    Write-Warning "Unable to get App Principal for $($uri.Host). Unable to check permissions for this Exchange Server"
                    $anyWarnings = $true
                }
            }
            else
            {
                Write-Warning "Found trusted Exchange Server at $($uri.Host) but it is not a Self Issuer"
                $anyWarnings = $true
            }
        }
    }

    if(-not $foundTrustedIssuer)
    {
        Write-Warning "Unable to find any trusted Exchange Servers"
        $anyWarnings = $true
    }
}
else
{
    Write-Warning "Unable to find any trusted Exchange Servers"
    $anyWarnings = $true
}

Write-Host
Write-Host
Write-Host "Step 4: Report current Site Mailbox Configuration"

if($webapps -ne $NULL)
{
    foreach($webapp in $webapps)
    {
        Write-Host
        Write-Host "Web Application Site Mailbox Configuration: $($webapp.Url)"
        Write-Host "Exchange Site Mailbox Domain: $($webapp.Properties["ExchangeTeamMailboxDomain"])"
        
        if($webapp.Properties["ExchangeAutodiscoverDomain"] -ne $NULL)
        {
            Write-Host "Exchange Autodiscover Domain: $($webapp.Properties["ExchangeAutodiscoverDomain"])"
        }
    }
}

Write-Host
Write-Host "Trusted Exchange Services: $([String]::Join(", ", $trustedIssuerHosts))"

$feature = Get-SPFeature CollaborationMailboxFarm -Farm -ErrorAction Ignore

if($feature -eq $NULL)
{
    Write-Host -ForegroundColor Red "Site Mailboxes are NOT enabled for Farm"
}
else
{
    Write-Host -ForegroundColor Green "Site Mailboxes are enabled for Farm"
}

if($ReturnWarningState)
{
    return $anyWarnings
}

將兩個 two .ps1 檔案儲存在 SharePoint Server 伺服器上的相同資料夾中,因為其中一個指令碼在執行時會呼叫另一個指令碼。在 Microsoft PowerShell 視窗 (在 PowerShell 圖示按一下滑鼠右鍵,然後選擇 [以系統管理員身分執行] 來開啟),瀏覽至包含 .ps1 檔案的資料夾,然後執行 Set-SiteMailboxConfig.ps1 指令碼。這可讓使用者執行下列作業:

  • 擷取並安裝 Exchange 中繼資料,提供 Exchange 服務主體對 SharePoint 網站訂閱的完全控制權限

  • 啟用在 SharePoint 環境中的網站信箱功能

  • (選用) 如果未設定自動探索的網域 DNS,則設定 Exchange 網站信箱目標網域

Check-SiteMailboxConfig.ps1 會在 Set-SiteMailboxConfig 指令碼當中呼叫,且它會確認設定成功 (也可個別執行)。

格式應如下所示:

.\Set-SiteMailboxConfig.ps1 -ExchangeSiteMailboxDomain <網域> -ExchangeAutodiscoverDomain [Exchange Server] -WebApplicationUrl [URL]

其中 <網域> 為 Exchange Server 所在網域的 FQDN,<Exchange Server> 為要連線的 Exchange Server。這是必要參數。

選用的參數為 [Exchange Server],這是您要連線的 Exchange Server (在未啟用或適當設定自動探索時需要此項) 和 [URL],這是您可能在設定的特定 URL (通常用於具有 SSL 及非 SSL Web 應用程式的環境)。

範例: .\Set-SiteMailboxConfig.ps1 -ExchangeSiteMailboxDomain tailspintoys.com -ExchangeAutodiscoverDomain exchange1.tailspintoys.com -WebApplicationUrl https://tailspintoys.com

若執行指令碼時發生錯誤,請參考本文章的<疑難排解>一節尋求指引。

設定網站信箱的 Exchange Server

最後一個步驟是在 Exchange Server 上建立 OAuth 信任及服務權限。

在 Exchange 上建立 OAuth 信任及服務權限

  1. 在 Exchange Server 上以系統管理員身分開啟 Exchange Management PowerShell 視窗,然後變更至 "C:\Program Files\Microsoft\Exchange Server\V15\Scripts" 目錄。

  2. 執行下列命令:

    .\Configure-EnterprisePartnerApplication.ps1 -ApplicationType Sharepoint -AuthMetadataUrl https://<SP_FQDN>/_layouts/15/metadata/json/1
    

    其中 <SP_FQDN> 為要設定之 SharePoint SSL 根網站集合的 URL。

疑難排解

若發生問題,請檢閱下列表格。

當您執行設定檢查清單指令碼時供參考的錯誤碼表格

錯誤碼 錯誤 附註

0

NoError

檢閱必要條件。

1

ExchangeClientNotAvailable

在 SharePoint WFE 上找不到 EWS 用戶端。請執行檢查指令碼並確認項目正確地位於 GAC 中;您可能需要重新安裝 EWS 用戶端。

2

UnsupportedVersion

EWS 用戶端版本與 SharePoint 不相容。請執行檢查指令碼,確認版本符合最低需求。或者,Exchange Server 可能是 2010 或更早的版本。

3

InvalidUser

TeamMailboxDomain 參數不是有效的 FQDN 或 SMTP 位址。

4

UnauthorizedUser

指令碼從 Exchange Server 收到 401 錯誤訊息,請檢閱 Exchange 設定步驟。

5

ServerBusy

Exchange 在自動探索期間逾時。這應該是間歇性發生的問題,請重試。但若持續發生,請詢問 Exchange 系統管理員。

6

URLNotAvailable

自動探索無法傳回 ECP/OWA 的 URL,這通常表示 EWS 用戶端版本與 SharePoint 不相容。也可能表示 Exchange 未啟用網站信箱,這就必須進一步詢問 Exchange 系統管理員。

7

OAuthNotSupported

代表 SharePoint 產生 OAuth 權杖時失敗。這通常是 SharePoint Web 應用程式停用宣告式驗證造成的。

8

OAuthException

SharePoint 和 Exchange 之間的 OAuth 交握期間發生錯誤。這通常是伺服器對伺服器的設定問題所造成,例如任一方領域值不符、Exchange 或 SharePoint 的憑證問題等。請檢閱憑證,然後嘗試建立或重新建立信任。

9

InvalidAutodiscoverDomain

自動探索網域屬性未設為有效的 FQDN。

10

UnknownError

發生不明錯誤狀況。請執行檢查指令碼,並確認有效、受信任的 SharePoint 執行個體可用、檢閱必要條件、向 Exchange 系統管理員確認自動探索已正確設定。

101

OAuthNotSupportedOverHttp

系統若擲回此錯誤、Web 應用程式的預設區域未設為 SSL 且 AllowOauthoverHttp 也設為 False。請執行檢查指令碼,確認任何要代管網站信箱的 Web 應用程式在預設區域都已使用 SSL 進行設定,如必要條件中所概述一般。

102

AssociatedOwnersGroupNull

網站的預設「擁有人」和「成員」群組其中之一或兩者皆已刪除。對於使用者要安裝網站信箱的任何網站,都需要存在這兩個預設群組。網站管理員應可指示網站擁有人重新建立這些必要的群組。

103

ExchangeTeamMailboxDomainNotSet

未設定 ExchangeTeamMailboxDomain 屬性。

104

ExchangeAppPrincipalNotFound

找不到信任的 Exchange 應用程式主體。這通常表示遺漏 New-SPTrustedSecureTokenService 步驟。請執行檢查指令碼,確認輸出的應用程式主體 URL 是正確的。

105

ExchangeAppPrincipalMissingPermissions

連線的 Exchange 應用程式主體在 SharePoint 伺服器陣列上沒有適當的權限。請執行檢查指令碼,確認 Exchange 應用程式主體在伺服器陣列上具備必要權限。

See also

Plan email integration for a SharePoint Server farm
Configure email integration for a SharePoint Server farm

站台信箱
共同作業