【问题标题】:ASP.NET website -> WCF service -> WCF service, with impersonation all the way?ASP.NET网站->WCF服务->WCF服务,一路冒充?
【发布时间】:2011-02-24 16:54:56
【问题描述】:

简而言之,我的场景是这样的:

  1. 用户在 Web 浏览器中触发一个操作,这会导致对 Web 服务器(服务器 A)中的 Web 服务的 Ajax 调用。
  2. Web 服务器向 IIS 中托管的 WCF 服务发出调用(服务器 B)
  3. WCF 服务向 IIS 中托管的另一个 WCF 服务发出调用(服务器 C)

所有网站都通过 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)

调整服务绑定对我来说就像在冰上行走一样薄,我几乎是在水上行走,所以让我们忽略到目前为止我失败的地方,并从一张干净的床单开始。

我应该如何配置服务以使其彼此(和我)很好地配合?

【问题讨论】:

  • 你的用户是来自 xkcd 的人吗? :-)

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


【解决方案1】:

根据微软的说法,你需要使用一种叫做“委托”的东西,如果我理解正确的话,就是指定服务器 C 信任服务器 B 来正确地验证来自服务器 A 的用户。

如果没有委托,服务器 B 上的服务只能以服务器 A 的模拟用户身份访问本地资源。

来自马口:http://msdn.microsoft.com/en-us/library/cc949014.aspx

【讨论】:

  • 这看起来很有希望。看看我明天能不能在办公室试试。
【解决方案2】:

因为您要进行不止一跳,所以您需要使用委托。请查看here 了解更多信息。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2011-04-24
    • 1970-01-01
    • 1970-01-01
    • 2013-10-08
    • 2013-02-08
    • 2011-03-14
    • 2017-03-10
    相关资源
    最近更新 更多