要求に対応する WCF サービス

Visual Studio で、[ファイル] メニューを開き、[新規作成]、[Web サイト] の順に選択します。 要求に対応する WCF サービスを選択します。

web.config ファイルを見ると、通常の WCF サービスの web.config とは多くの違いがあることがわかります。

  • assemblies 要素に WIF アセンブリが含まれています。

    <add assembly="Microsoft.IdentityModel, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
    
  • services 要素には、新しいサービスが含まれています。

    <service name="ClaimsAwareService1.Service" behaviorConfiguration="ClaimsAwareService1.ServiceBehavior">
    
  • services 要素には、新しいエンドポイントも含まれています。

    <endpoint address="" binding="wsHttpBinding" contract="ClaimsAwareService1.IService">
    
  • serviceBehavior 要素には、新しいサービス動作が含まれています。

    <behaviors> <serviceBehaviors> <behavior name="ClaimsAwareService1.ServiceBehavior" > <!-- Behavior extension to make the service claims aware --> <federatedServiceHostConfiguration/> <!-- To avoid disclosing metadata information, set the value below to false and remove the metadata endpoint above before deployment --> <serviceMetadata  httpGetEnabled="true"/> <!-- To receive exception details in faults for debugging purposes, set the value below to true.  Set to false before deployment to avoid disclosing exception information --> <serviceDebug includeExceptionDetailInFaults="false"/> </behavior> </serviceBehaviors> </behaviors>
    
  • 最後に、extensions 要素が system.serviceModel 要素に追加されています。

    <extensions> <behaviorExtensions> <!-- This behavior extension will enable the service host to be Claims aware --> <add name="federatedServiceHostConfiguration" type="Microsoft.IdentityModel.Configuration.ConfigureServiceHostBehaviorExtensionElement, Microsoft.IdentityModel, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/> </behaviorExtensions> </extensions>
    

ここで、FedUtil を使用すると、IClaimsPrincipal を介して現在のユーザーの要求にアクセスできます。 詳細については、「WCF 証明書利用者アプリケーションを構築する方法」を参照してください。