无法让 WCF Web 服务与 Windows 身份验证一起使用

发布于 2025-01-08 12:23:07 字数 1680 浏览 4 评论 0原文

我已经编写了我的第一个 WCF Web 服务,它在我自己的本地测试 Web 服务器上运行良好,但是当我将其部署到 IIS 时遇到错误。

我们的 IIS 服务器使用集成身份验证,并且不允许允许匿名访问。来自我读过的内容,我需要将绑定的安全模式设置为 TransportCredentialOnlyweb.config 中的整个部分是:

  <system.serviceModel>
    <behaviors>
      <endpointBehaviors>
        <behavior name="VZW.TrainingPortfolioManager.Website.TPMAspNetAjaxBehavior">
          <enableWebScript />
        </behavior>
      </endpointBehaviors>
    </behaviors>
    <serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />
    <services>
      <service name="VZW.TrainingPortfolioManager.Website.TPM">
        <endpoint address="" behaviorConfiguration="VZW.TrainingPortfolioManager.Website.TPMAspNetAjaxBehavior"
          binding="webHttpBinding" contract="VZW.TrainingPortfolioManager.Website.TPM" />
      </service>
    </services>
    <bindings>
      <basicHttpBinding>
        <binding>
          <security mode="TransportCredentialOnly">
            <transport clientCredentialType="Windows" />
          </security>
        </binding>
      </basicHttpBinding>      
    </bindings>
  </system.serviceModel>

但是,当我在浏览器中加载 Web 服务时,我收到错误消息:

Security settings for this service require 'Anonymous' Authentication but it is not enabled for the IIS application that hosts this service.

我还需要更改或配置其他内容才能使其正常工作吗?

I've written my first WCF web service, which works great on my own local test webserver, however I'm getting an error when I deploy it to IIS.

Our IIS server uses integrated auth, and does not allow anonymous access. From what I've read, I need to set the security mode on the binding to TransportCredentialOnly. The entire section in web.config is:

  <system.serviceModel>
    <behaviors>
      <endpointBehaviors>
        <behavior name="VZW.TrainingPortfolioManager.Website.TPMAspNetAjaxBehavior">
          <enableWebScript />
        </behavior>
      </endpointBehaviors>
    </behaviors>
    <serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />
    <services>
      <service name="VZW.TrainingPortfolioManager.Website.TPM">
        <endpoint address="" behaviorConfiguration="VZW.TrainingPortfolioManager.Website.TPMAspNetAjaxBehavior"
          binding="webHttpBinding" contract="VZW.TrainingPortfolioManager.Website.TPM" />
      </service>
    </services>
    <bindings>
      <basicHttpBinding>
        <binding>
          <security mode="TransportCredentialOnly">
            <transport clientCredentialType="Windows" />
          </security>
        </binding>
      </basicHttpBinding>      
    </bindings>
  </system.serviceModel>

However, when I load the web service in the browser, I get the error message:

Security settings for this service require 'Anonymous' Authentication but it is not enabled for the IIS application that hosts this service.

Is there anything else I need to change or configure to get this working?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

十年不长 2025-01-15 12:23:07

想通了。 endpoint 上的 binding 属性必须与 集合中的节点匹配。以下将起作用:

<bindings>
  <webHttpBinding>
    <binding>
      <security mode="TransportCredentialOnly">
        <transport clientCredentialType="Windows" />
      </security>
    </binding>
  </webHttpBinding>      
</bindings>

Figured it out. The binding attribute on the endpoint has to match the node in the <bindings> collection. The following will work:

<bindings>
  <webHttpBinding>
    <binding>
      <security mode="TransportCredentialOnly">
        <transport clientCredentialType="Windows" />
      </security>
    </binding>
  </webHttpBinding>      
</bindings>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文