Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/wcf/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/security/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何模拟wcf调用的客户端_Wcf_Security_Impersonation - Fatal编程技术网

如何模拟wcf调用的客户端

如何模拟wcf调用的客户端,wcf,security,impersonation,Wcf,Security,Impersonation,我需要一些关于WCF和授权的帮助。 目前,我有一个客户端,它以.NET远程处理对象的形式调用windows服务中托管的对象,并且正在调用WCF服务(使用wshttpbinding)。 WCF服务正在使用基于消息的安全性的windows身份验证 windows服务正在使用特殊帐户运行。 一旦客户端调用到达.NET远程处理对象,thread.currentprincipal将被设置为客户端提供的主体,以便使用客户端提供的凭据执行所有操作。 到目前为止没有问题,现在是我当前的问题: 应使用客户端用户凭

我需要一些关于WCF和授权的帮助。 目前,我有一个客户端,它以.NET远程处理对象的形式调用windows服务中托管的对象,并且正在调用WCF服务(使用wshttpbinding)。 WCF服务正在使用基于消息的安全性的windows身份验证

windows服务正在使用特殊帐户运行。 一旦客户端调用到达.NET远程处理对象,thread.currentprincipal将被设置为客户端提供的主体,以便使用客户端提供的凭据执行所有操作。 到目前为止没有问题,现在是我当前的问题: 应使用客户端用户凭据调用wcf服务。Afaik WCF使用WindowsIdentity.GetCurrent创建呼叫的授权信息。由于Thread.CurrentPrincipal持有我要用于调用的标识,我认为(hread.CurrentPrincipal.identity作为WindowsIdentity)。Impersonate()完成此任务

但现在我得到的不是WCF安全异常,而是以下异常: System.ComponentModel.Win32异常:安全包中没有可用的凭据

调用堆栈: 位于System.IdentityModel.SspiWrapper.AcquireCredentialsHandle(字符串包、CredentialUse意图、AuthIdentityEx和authdata) 位于System.ServiceModel.Security.SecurityUtils.GetCredentialsHandle(字符串包、NetworkCredential凭据、布尔isServer、字符串[]附加包) 位于System.ServiceModel.Security.SecurityUtils.GetCredentialsHandle(SecurityBindingElement sbe、ClientCredentials和ClientCredentials) 位于System.ServiceModel.Security.SecurityUtils.GetCredentialsHandle(SecurityBindingElement sbe,BindingContext上下文) 位于System.ServiceModel.Security.SecuritySessionSecurityTokenProvider.OnOpen()处 位于System.ServiceModel.Security.WrapperSecurityCommunicationObject.OnOpen()处 在System.ServiceModel.Channels.CommunicationObject.Open处(TimeSpan超时) 位于System.ServiceModel.Security.CommunicationObjectSecurityTokenProvider.Open(TimeSpan超时) 位于System.ServiceModel.Security.SecurityUtils.OpenTokenProviderFrequeuired(SecurityTokenProvider tokenProvider,TimeSpan超时) 位于System.ServiceModel.Security.SecuritySessionClient设置'1.ClientSecuritySessionChannel.OnOpen(TimeSpan超时) 在System.ServiceModel.Channels.CommunicationObject.Open处(TimeSpan超时) 在System.ServiceModel.Channels.ServiceChannel.OnOpen(TimeSpan超时)处 在System.ServiceModel.Channels.CommunicationObject.Open处(TimeSpan超时) 在System.ServiceModel.Channels.ServiceChannel.CallOpenOnce.System.ServiceModel.Channels.ServiceChannel.iAllonce.Call中(ServiceChannel通道,TimeSpan超时) 在System.ServiceModel.Channels.ServiceChannel.CallOnceManager.CallOnce(TimeSpan超时,CallOnceManager级联) 在System.ServiceModel.Channels.ServiceChannel.com上重新打开(TimeSpan超时) 在System.ServiceModel.Channels.ServiceChannel.Call(字符串操作、布尔单向、ProxyOperationRuntime操作、对象[]输入、对象[]输出、时间跨度超时) 在System.ServiceModel.Channels.ServiceChannel.Call(字符串操作、布尔单向、ProxyOperationRuntime操作、对象[]输入、对象[]输出) 位于System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCallMessage方法调用,ProxyOperationRuntime操作) 位于System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage消息)

谢谢你的帮助 马丁

编辑:我犯了一个导致此异常的错误,因为我忘记在模拟之后创建channelfactory,但现在我遇到了另一个异常,我不确定如何处理它:
System.IO.FileLoadException:无法加载文件或程序集'System.IdentityModel.Selectors,版本=3.0.0.0,区域性=中性,PublicKeyToken=b77a5c561934e089'或其依赖项之一。未提供所需的模拟级别,或者提供的模拟级别无效。(HRESULT的例外:0x80070542)

必须允许运行windows服务的用户模拟用户

有一个名为“身份验证后模拟客户端”的权限