SharePoint Server でサイト メールボックスを構成する

適用対象:yes-img-13 2013yes-img-162016 yes-img-192019 yes-img-seSubscription Edition no-img-sopSharePoint in Microsoft 365

この記事では、SharePoint Server および Exchange Server にサイト メールボックスを構成する方法を説明します。 サイト メールボックス機能によって、SharePoint Server ユーザーはサイトでチーム宛て電子メールを使用できます。 また、Microsoft Outlook に SharePoint ドキュメント ライブラリへのリンクが表示され、ユーザーは共同プロジェクトで作業しているチームの他のメンバーとファイルや電子メール メッセージを共有できます。

はじめに

この操作を開始する前に、前提条件に関する次の情報を確認してください。

  • サイト メールボックスには、2013 以降Exchange Serverが必要です。

  • Exchange Web サービス (EWS) の以前のバージョンを SharePoint サーバーからすべてアンインストールする必要があります。

    注:

    EWS の以前のバージョンがインストールされているかどうかの確認が必要な場合があります。 その場合、以下に示されている Check-SiteMailboxConfig スクリプトを実行してください。

  • サイト メールボックス機能では、ユーザー プロファイルの同期がファームで構成されている必要があります。 ユーザー プロファイルの同期の構成については、「ユーザー プロファイルと ID を計画する」と「ユーザー プロファイルの同期を管理する (SharePoint Server)」を参照してください。

  • サイト メールボックス機能を使用するには、アプリ管理サービス アプリケーションがファームに構成されている必要があります。 アプリ管理サービス アプリケーションの構成については、「New-SPAppManagementServiceApplication」を参照してください。

  • 既定のゾーンに対して構成された Secure Sockets Layer (SSL) が、サーバー間認証とアプリ認証をサポートするシナリオに展開された Web アプリケーションの要件の 1 つとなります。 これはまさにそのようなシナリオです。 サイト メールボックスを構成するための前提条件として、SharePoint Server を実行しているコンピューターに SSL が構成されている必要があります。 詳細については、「SharePoint Server でクレーム ベースの Web アプリケーションを作成する」を参照し、SSL サイト コレクションとサーバー証明書を作成する手順に従ってください。

Exchange Server SSL 証明書を Exchange Server から SharePoint Server にインポートし、SharePoint Server から Exchange Server にインポートする必要がある場合があることに注意してください。 これは、API エンドポイント (ラボ環境のセルフ SSL 証明書など) に対して証明書が信頼されていない場合にのみ必要です。 信頼されていない SSL 証明書を新しいサーバーにインポートするには

  • Internet Explorer を開き、SharePoint Server に展開されている場合は Outlook Web App に、または Exchange Server に展開されている場合は SSL SharePoint サイトに移動します (https://<ExServerName>/owa または https://<SP_FQDN>)。

  • [Web サイトに進む] をクリックし、証明書を受け入れて信頼します。

  • 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. EWSManagedAPI.msi を Microsoft ダウンロード センター からダウンロードし、各 Web サーバーとアプリケーション サーバー上のフォルダーに保存します。

  2. 管理者としてコマンド ウィンドウを開き、EWSManagedAPI.msi を保存したフォルダーに移動します。

  3. 次のコマンドを実行します。

    msiexec /I EwsManagedApi.msi addlocal="ExchangeWebServicesApi_Feature"
    
  4. コマンドラインから次のように入力して IIS をリセットします。 IISReset.

SharePoint Server で OAuth Trust およびサービスのアクセス許可を確立する

次の手順は、以下の 2 つのスクリプトをコピーすることです。 1 番目のスクリプトを Set-SiteMailboxConfig.ps1 として保存し、2 番目のスクリプトを 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) doesn't 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
}

一方のスクリプトが、実行中にもう一方のスクリプトを呼び出すので、2 つの .ps1 ファイルを SharePoint Server フロントエンド サーバーまたはアプリケーション サーバーの同じフォルダーに保存します。 Microsoft PowerShell ウィンドウ (PowerShell アイコンを右クリックして [管理者として実行] を選択して開く) で, .ps1 ファイルが含まれるフォルダーに移動し、Set-SiteMailboxConfig.ps1 スクリプトを実行します。 これにより、ユーザーは以下を実行できます。

  • Exchange メタデータを取得してインストールし、Exchange サービス プリンシパルに SharePoint サイト サブスクリプションに対するフル コントロールのアクセス許可を付与する

  • SharePoint 環境でサイト メールボックス機能を有効にする

  • (オプション) ドメインの DNS が AutoDiscover 用に構成されていない場合、Exchange サイト メールボックス ターゲット ドメインを設定する

Check-SiteMailboxConfig.ps1 は Set-SiteMailboxConfig スクリプトの一部として呼び出され、構成が正常に完了したことを確認します (これを別途実行することもできます)。

形式は次のようになります。

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

ここで、<ドメイン> は、Exchange Server が含まれるドメインの FQDN であり、<Exchange Server> は、接続先の Exchange Server です。 これは必須パラメーターです。

オプション パラメーターの [Exchange Server] は接続先の Exchange Server で (これは Autodiscover が無効か、または適切に構成されていない場合に必要です)、[URL] は構成できる特定の URL です (通常は、SSL の Web アプリケーションおよび非 SSL の Web アプリケーションを含む環境で使用されます)。

例:

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

スクリプトの実行中にエラーが発生した場合、この記事にある「トラブルシューティング」セクションを参照してください。

サイト メールボックス用に Exchange Server を構成する

最後の手順は、Exchange Server で OAuth Trust およびサービス権限を確立することです。

Exchange で OAuth Trust およびサービス権限を確立する

  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
EWS クライアントが SharePoint WFE で見つかりませんでした。 Check スクリプトを実行し、エントリが 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
AutoDiscover ドメイン プロパティが有効な FQDN に設定されていません。
10
UnknownError
不明なエラー状態が発生しました。 チェック スクリプトを実行し、SharePoint の有効で信頼できるインスタンスが使用可能であることを確認し、前提条件を確認し、Exchange 管理者と共に自動検出が適切に設定されていることを確認します。
101
OAuthNotSupportedOverHttp
このエラーがスローされた場合、Web アプリケーションの既定のゾーンが SSL に設定されておらず、AllowOauthoverHttp も false に設定されています。 チェック スクリプトを実行し、サイト メールボックスをホストするすべての Web アプリケーションの既定のゾーンに、前提条件に示されているように、SSL が設定されていることを確認します。
102
AssociatedOwnersGroupNull
サイトの既定の所有者グループとメンバー グループの一方または両方が削除されています。 これら 2 つの既定のグループはいずれも、ユーザーがサイト メールボックスをインストールするすべてのサイトに存在する必要があります。 サイト管理者は、サイト所有者にこれらの必要なグループを再作成するように指示できる必要があります。
103
ExchangeTeamMailboxDomainNotSet
ExchangeTeamMailboxDomain プロパティが設定されていません。
104
ExchangeAppPrincipalNotFound
信頼できる Exchange アプリ プリンシパルが見つかりませんでした。 通常、これは、New-SPTrustedSecureTokenService 手順が行われなかったことを意味します。 チェック スクリプトを実行し、出力されたアプリ プリンシパルの URL が適切な URL であることを確認します。
105
ExchangeAppPrincipalMissingPermissions
接続先の Exchange アプリ プリンシパルに、SharePoint ファームに対する適切なアクセス許可がありません。 チェック スクリプトを実行し、Exchange アプリ プリンシパルに、ファームに対する必要なアクセス許可があることを確認します。

関連項目

概念

Plan email integration for a SharePoint Server farm

Configure email integration for a SharePoint Server farm

その他のリソース

サイト メールボックス

グループ作業