ASP.NET网站 - > WCF服务 - > WCF服务,一路冒充?

时间:2010-05-27 14:23:34

标签: .net asp.net wcf wcf-binding

简而言之,我的情况是这样的:
alt text

  1. 用户在Web浏览器中触发操作,这会导致对Web服务器(服务器A )中的Web服务进行Ajax调用。
  2. Web服务器发出对IIS中托管的WCF服务的调用(服务器B
  3. WCF服务发出对IIS中托管的另一个WCF服务的调用(服务器C
  4. 所有网站都通过http公开,而不是https。

    现在,服务器C需要知道用户在另一端的用户。到目前为止,我已将其工作,以便在模拟下执行对服务器B的WCF服务调用,因此服务器B具有表示用户的WindowsIdentity对象。但是,当我尝试在模拟时调用从服务器B到服务器C的服务调用时,我得到以下内容:

    System.ComponentModel.Win32Exception: No credentials are available in the security package
    
    Server stack trace: 
       at System.IdentityModel.SspiWrapper.AcquireCredentialsHandle(String package, CredentialUse intent, AuthIdentityEx& authdata)
       at System.ServiceModel.Security.SecurityUtils.GetCredentialsHandle(String package, NetworkCredential credential, Boolean isServer, String[] additionalPackages)
       at System.ServiceModel.Security.SpnegoTokenProvider.OnOpening()
       at System.ServiceModel.Security.WrapperSecurityCommunicationObject.OnOpening()
       at System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan timeout)
       at System.ServiceModel.Security.CommunicationObjectSecurityTokenProvider.Open(TimeSpan timeout)
       at System.ServiceModel.Security.SecurityUtils.OpenTokenProviderIfRequired(SecurityTokenProvider tokenProvider, TimeSpan timeout)
       at System.ServiceModel.Security.SymmetricSecurityProtocol.OnOpen(TimeSpan timeout)
       at System.ServiceModel.Security.WrapperSecurityCommunicationObject.OnOpen(TimeSpan timeout)
       at System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan timeout)
       at System.ServiceModel.Channels.SecurityChannelFactory`1.ClientSecurityChannel`1.OnOpen(TimeSpan timeout)
       at System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan timeout)
       at System.ServiceModel.Channels.ServiceChannel.OnOpen(TimeSpan timeout)
       at System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan timeout)
       at System.ServiceModel.Channels.ServiceChannel.CallOpenOnce.System.ServiceModel.Channels.ServiceChannel.ICallOnce.Call(ServiceChannel channel, TimeSpan timeout)
       at System.ServiceModel.Channels.ServiceChannel.CallOnceManager.CallOnce(TimeSpan timeout, CallOnceManager cascade)
       at System.ServiceModel.Channels.ServiceChannel.EnsureOpened(TimeSpan timeout)
       at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs, TimeSpan timeout)
       at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs)
       at System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCallMessage methodCall, ProxyOperationRuntime operation)
       at System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage message)
    

    调整服务绑定对我来说就像在冰上行走一样瘦,以至于我差点在水上行走,所以让我们忽视我到目前为止失败的情况,并从一张干净的床单开始。

    我应该如何配置服务以便彼此(和我)很好地玩耍?

2 个答案:

答案 0 :(得分:4)

根据Microsoft的说法,您需要使用名为“Delegation”的东西,如果我理解正确,则指定服务器C信任服务器B以从服务器A正确地验证用户。

如果没有委派,您在服务器B上的服务只能作为来自服务器A的模拟用户访问本地资源。

从马的口中:http://msdn.microsoft.com/en-us/library/cc949014.aspx

答案 1 :(得分:2)

因为您要制作多个跃点,所以需要使用委托。请查看here以获取更多信息。