Service WCF prenant en charge les revendications
Dans Visual Studio, ouvrez le menu Fichier et sélectionnez Nouveau, puis Site Web. Sélectionnez Service WCF prenant en charge les revendications.
Si vous observez votre fichier web.config, vous pouvez voir plusieurs différences par rapport au fichier web.config d'un service WCF par défaut.
L'élément
assemblies
inclut à présent l'assembly WIF :<add assembly="Microsoft.IdentityModel, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
L'élément
services
contient un nouveau service :<service name="ClaimsAwareService1.Service" behaviorConfiguration="ClaimsAwareService1.ServiceBehavior">
L'élément
services
contient également un nouveau point de terminaison :<endpoint address="" binding="wsHttpBinding" contract="ClaimsAwareService1.IService">
L'élément
serviceBehavior
contient un nouveau comportement de service :<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>
Enfin, un élément
extensions
est ajouté à l'élémentsystem.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>
Vous pouvez maintenant utiliser FedUtil pour accéder aux revendications de l'utilisateur actuel via IClaimsPrincipal. Pour plus d'informations, consultez Procédure : Générer une application de partie de confiance WCF.