BizTalk WCF-webhttp 和 IIS:如何处理身份验证和授权,ASP.NET 兼容性或自定义?

BizTalk WCF-webhttp and IIS: How to handle authentication and authorization, ASP.NET compatibility or custom?

我已经使用 WCF 服务发布向导发布了 WCF 服务(这似乎是我能找到的创建 WCF 服务以供 WCF-webhttp 接收适配器使用的唯一方法)。我想在 IIS 中使用 ASP.NET 身份验证。

根据this文章:

...the WCF security model does not adhere to any URL-based authorization rules specified in System.Web’s configuration element...WCF’s ASP.NET compatibility mode is suitable for scenarios that do not require the ability to host outside of IIS or to communicate over protocols other than HTTP. WCF’s ASP.NET compatibility mode is enabled at the application level through the following configuration (located in the application’s Web.config file):

<system.serviceModel>  
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" />  
</system.serviceModel>  

但是,当向服务发出客户端请求时,我收到 "The service cannot be activated because it does not support ASP.NET compatibility" 错误。根据 articles 我在此发现,必须在设计时将 AspNetCompatibilityRequirementsMode 属性添加到服务 class。如果使用 WCF 发布向导,如何做到这一点?我找不到任何解释如何创建自定义 BizTalk WCF 服务的文章。

答案是按照 this 演练来构建自定义行为。自定义行为检查对 WCF 服务的传入请求的用户安全主体,并确定它是否满足 ASP.NET 授权要求的要求。这允许您从 IIS 中控制 WCF service/site 授权。