0

我有一个在 Windows 2008 机器上的 IIS 7 下运行的 .Net 3.5 SP1 WCF 服务。当我尝试从在 IIS 5.0 (Windows XP) .Net 3.5 SP1 下运行的 IIS 托管 WCF 服务连接到此服务时,我收到以下错误:

令牌提供程序无法获取目标令牌:http://( WCF 服务的 URL)

我构建了一个简单的控制台应用程序,它可以使用完全相同的配置成功连接到 WCF 服务。我还在 WebDev 服务器(Visual Studio 2008 附带的 ASP.Net 服务器)下构建了一个简单的 Web 应用程序,它能够成功连接到 WCF 服务。当我在 IIS (Windows XP) 中配置一个虚拟目录以指向与 WebDev 服务器相同的目录时,我收到以下错误:

安全包中没有可用的凭据

但是,如果我将 web.config 设置为使用我的登录凭据打开模拟,它就可以正常工作。由于显而易见的原因,这不是一个好的长期解决方案。我注意到 IIS 和 WebDev 服务器之间的一个区别是每个进程在其下运行的用户。IIS 在 ASPNet 帐户下运行,WebDev 在我的帐户下运行。

这是客户端上 WCF 部分的配置:

<system.serviceModel>
<behaviors>
  <serviceBehaviors>
    <behavior name="mexBehavior">
      <serviceMetadata httpGetEnabled="true" />
      <serviceDebug includeExceptionDetailInFaults="true" />
      <serviceThrottling maxConcurrentCalls="200" maxConcurrentSessions="200" />
    </behavior>
  </serviceBehaviors>
</behaviors>
<bindings>
  <wsHttpBinding>
    <binding name="FABindings" maxReceivedMessageSize="2147483647">
      <readerQuotas maxStringContentLength="300000"/>
      <security mode="Message">
        <message clientCredentialType="Windows" negotiateServiceCredential="false" establishSecurityContext="false" />
      </security>
    </binding>
  </wsHttpBinding>
</bindings>
<client>
  <endpoint address="http://<server url>/FinancialAggregator/v3/Services/FAService.svc"
      binding="wsHttpBinding" bindingConfiguration="FABindings"
      contract="ServiceReference1.IFilteredService" name="FAServiceEndpoint">
    <identity>
      <servicePrincipalName value="<UsernameRunningTheAppPoolOnW2k8>" />
    </identity>
  </endpoint>
</client>  

这是服务器配置(根据要求):

  <system.serviceModel>
<bindings>
  <wsHttpBinding>
    <binding name="wsHttpBinding" maxReceivedMessageSize="2147483647">
      <security mode="Message">
        <message establishSecurityContext="false" negotiateServiceCredential="false" />
      </security>
    </binding>
  </wsHttpBinding>
</bindings>
<behaviors>
  <serviceBehaviors>
    <behavior name="mexBehavior">
      <serviceMetadata httpGetEnabled="true" httpsGetEnabled="false" />
      <serviceDebug includeExceptionDetailInFaults="true" />
      <serviceThrottling maxConcurrentCalls="200" maxConcurrentSessions="200" />
    </behavior>
  </serviceBehaviors>
</behaviors>
<services>
  <service behaviorConfiguration="mexBehavior" name="FCSAmerica.Financial.Aggregator.Service.FilteredService">
    <endpoint name="FAServiceEndpoint" address="" binding="wsHttpBinding" bindingConfiguration="wsHttpBinding" contract="FCSAmerica.Financial.Aggregator.Service.IFilteredService">
    </endpoint>
  </service>
</services>

关于这个错误的原因有什么想法吗?

谢谢!

4

2 回答 2

0

当您通过 IIS 访问服务时,impersonate = false,则它是用于访问 Windows 2008 机器上的服务的 ASPnet 帐户。

ASPnet 帐户是本地帐户,因此在 2008 机器上没有权限。

有 3 种方法可以解决此问题:

  • 允许匿名访问 Windows 2008 机器上的服务
  • 使用 impersonate = true (正如你所拥有的)
  • 将应用程序池的标识从 aspnet 更改为具有所需访问权限的域帐户。
于 2009-06-24T11:03:10.493 回答
0

我想这个问题的最终答案是简单地升级到一个允许您设置应用程序池身份的操作系统,这是我多年前所做的。

感谢您的考虑。

马特

于 2011-08-19T13:07:45.697 回答