はじめに
[SharePoint2013] on-premiseで[SharePoint Add-ins]を動作させるためには
「SharePoint-hosted」か「high-trust な Provider-hosted(高信頼アプリ)」のどちらかになります。
- 「SharePoint-hosted」の場合は
hostedされるURLが別名になります(実際にはSharePointです)ので、DNSやSharePointの「アプリ URL の構成」をする必要があります。
はまる、App for SharePoint 2013 (オンプレミス; on-premises) とVisual Stuidoでのsharepoint hoted apps アプリデバックの環境(enviroment) - 「high-trust な Provider-hosted(高信頼アプリ)」の場合は
[自己証明書 or 商用証明書]を使用してProvider-hosted(WebSite)を信頼済み(SecurityTokenService)にしなければいけません。信頼済みにしないとエラーになります。
詳細(high-trust な Provider-hosted(高信頼アプリ))
- 自己署名入り証明書の作成する。
- 証明書のフレンドリ名を指定する
- 証明書をエクスポートする
※pfx :後でVisual Studioにpfx(秘密キー入り証明書)を読み込ませます
例)
場所 [C:\Certs\HighTrustSampleCert.pfx]
password [password]
- .cer(秘密キーのない証明書)も作ります。
※.cer :後で、[SharePoint Security Token Service]に秘密キーのない証明書を読み込ませます
作成した証明書をダブルクリック
詳細タブのファイルコピーをクリックする
秘密キーをエクスポートしません。
保存します。
例)
場所 [C:\Certs\HighTrustSampleCert.cer]
結果以下のようになります。
- SharePoint Security Token Service の構成を行います。
注意:specificIssuerId はGUIDを自分で生成する必要があります。 以下を[SharePoint2013 管理シェル]を管理者から起動して実行します。
例
$publicCertPath = "C:\Certs\HighTrustSampleCert.cer" $certificate = New-Object System.Security.Cryptography.X509Certificates.X509Certificate2($publicCertPath) New-SPTrustedRootAuthority -Name "HighTrustSampleCert" -Certificate $certificate $realm = Get-SPAuthenticationRealm $specificIssuerId = "11111111-1111-1111-1111-111111111111" $fullIssuerIdentifier = $specificIssuerId + '@' + $realm New-SPTrustedSecurityTokenIssuer -Name "High Trust Sample Cert" -Certificate $certificate -RegisteredIssuerName $fullIssuerIdentifier –IsTrustBroker iisreset $serviceConfig = Get-SPSecurityTokenServiceConfig $serviceConfig.AllowOAuthOverHttp = $true $serviceConfig.Update()
- Visual Studioで[SharePoint Add-ins] [Provider-hosted]アプリを作成します。
※[Visual Studio] は[管理者と実行]すること- 新しいプロジェクト
- プロバイダー向けのホスト型
※SharePointのサイトはDeveloperサイトのテンプレートで作成したサイトにして下さい
- SharePoint2013にします。
※DLLのバージョンがonline, on-premiseと異なりますので注意して下さい
- [ASP.NET Webフォーム アプリケーション], [ASP.NET MVC Web アプリケーション]どちらでもよいです。
- [アプリの認証方法]で証明書を使用する(高信頼性が必要なSharePoint設置型アプリの場合)
例 [証明書の場所(秘密キー込み)]: [C:\Certs\HighTrustSampleCert.pfx] [パスワード]: password [発行者 ID]: 11111111-1111-1111-1111-111111111111
- プロジェクトを作成後[Web.config]を確認すると以下のようになっています。
- デバック実行してみます。(F5)
IEが起動するので、[信頼する]をクリックする
- 以下のように標準テンプレートのサンプルが表示され、名前をSharePointから取得しています。
- 新しいプロジェクト
- テストが終わり本番にリリースする際に証明書の入れ替えについては
以下のサイトの「ドメインが発行した証明書または商用証明書を使用してデバッグを完了する」を参考にして下さい
SharePoint の高信頼性アドインを作成する
参考
- SharePoint Add-ins: On-Premises と Office 365 で動く Add-in を作成するには (Authentication)
- SharePoint の高信頼性アドインを作成する
- Create high-trust SharePoint Add-ins
- はまる、App for SharePoint 2013 (オンプレミス; on-premises) とVisual Stuidoでのsharepoint hoted apps アプリデバックの環境(enviroment)
- SharePoint2013+VisualStudio2013 配置手順 ‘IIS アプリケーション プールのリサイクル’ でエラー
コメントを残す