Wcf WebClient-ServiceSecurityContext.Current.WindowsIdentity=null

Wcf WebClient-ServiceSecurityContext.Current.WindowsIdentity=null,wcf,rest,authentication,webclient,Wcf,Rest,Authentication,Webclient,我在Windows 2008(IIS 7.5)计算机上有一个WCF服务(访问数据库),通过WebClient从Excel(VSTO-Excel客户端驻留在内部网络上)调用(通过REST/webHttpBinding使用GET调用) 我希望将用户的凭据传递给WCF服务-然后我希望服务中的方法以登录到启动Excel的工作站的人的身份访问数据库,但我将获得401(未经授权) 在我拥有的客户端上(注意,“base”指的是我的类继承的WebClient类):- 在服务范围内,我有:- [Opera

我在Windows 2008(IIS 7.5)计算机上有一个WCF服务(访问数据库),通过WebClient从Excel(VSTO-Excel客户端驻留在内部网络上)调用(通过REST/webHttpBinding使用GET调用)

我希望将用户的凭据传递给WCF服务-然后我希望服务中的方法以登录到启动Excel的工作站的人的身份访问数据库,但我将获得401(未经授权)

在我拥有的客户端上(注意,“base”指的是我的类继承的WebClient类):-

在服务范围内,我有:-

    [OperationContract]
    [WebInvoke(Method = "GET", UriTemplate = "/GetSomeData", RequestFormat = WebMessageFormat.Json, ResponseFormat = WebMessageFormat.Json)]
    SomeDataClass GetSomeData();
服务配置:-

  <service name="zzzz.Service.xxxx.xxxx" behaviorConfiguration="DataExtractBehavior">
      <endpoint address="" binding="webHttpBinding" bindingConfiguration="DataExtractBinding" behaviorConfiguration="MyEndpointBehavior" contract="zzzz.Service.xxxx.Ixxxx">
    </endpoint>
  </service>
  ...
  <serviceBehaviors>
    <behavior name="DataExtractBehavior">
      <serviceMetadata httpGetEnabled="true" />
      <serviceDebug includeExceptionDetailInFaults="true" />
      <etwTracking profileName="EndToEndMonitoring Tracking Profile" />
    </behavior>
  </serviceBehaviors>
  ...
  <webHttpBinding>
    <binding name="DataExtractBinding">
      <security mode="TransportCredentialOnly">
        <transport clientCredentialType="Windows" ></transport>
      </security>
    </binding>
  </webHttpBinding>
</bindings>
...

...
...
...
ConnectionString包括“集成安全性=SSPI”

注意事项:

  • 当我调用一个只返回字符串的伪方法(没有数据库调用)时,我得到了一个成功的响应(没有问题)
  • 在WCF服务内部,据我所知(通过跟踪),它正在数据库调用中崩溃(可能是因为它无法登录/验证数据库)
  • 同样在WCF方法中,ServiceSecurityContext.Current.WindowsIdentity似乎为null
  • 当服务托管在我的工作站上(连接到数据库的本地实例)时,我可以访问服务中的方法:当我部署到一台我没有相同权限的开发机器上时,问题就会出现
  • 我尝试了NetworkCredentials(默认和硬编码的userIs/password/domain)
  • 我启用了Windows身份验证和ASP.NET身份验证(我只尝试了带Anon/ASP.NET/nothing-other的Windows身份验证,结果不一-从未成功,只是返回了一个不同的返回码)
  • 模拟当前未设置,但我已尝试将其设置为true(收到500个)
是否有人知道如何在上述场景中成功发送用户的凭据(从而解决HTTP 401问题)

问候
特拉维斯

  <service name="zzzz.Service.xxxx.xxxx" behaviorConfiguration="DataExtractBehavior">
      <endpoint address="" binding="webHttpBinding" bindingConfiguration="DataExtractBinding" behaviorConfiguration="MyEndpointBehavior" contract="zzzz.Service.xxxx.Ixxxx">
    </endpoint>
  </service>
  ...
  <serviceBehaviors>
    <behavior name="DataExtractBehavior">
      <serviceMetadata httpGetEnabled="true" />
      <serviceDebug includeExceptionDetailInFaults="true" />
      <etwTracking profileName="EndToEndMonitoring Tracking Profile" />
    </behavior>
  </serviceBehaviors>
  ...
  <webHttpBinding>
    <binding name="DataExtractBinding">
      <security mode="TransportCredentialOnly">
        <transport clientCredentialType="Windows" ></transport>
      </security>
    </binding>
  </webHttpBinding>
</bindings>
...