Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/sql-server/26.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
C# WCF、实体框架和模拟_C#_Sql Server_Entity Framework_Wcf - Fatal编程技术网

C# WCF、实体框架和模拟

C# WCF、实体框架和模拟,c#,sql-server,entity-framework,wcf,C#,Sql Server,Entity Framework,Wcf,我正在开发一个WCF服务,它使用windows身份验证来验证客户端凭据 使用这种绑定,效果非常好 <basicHttpBinding> <binding> <security mode="TransportCredentialOnly"> <transport clientCredentialType="Windows" /> </security> </

我正在开发一个WCF服务,它使用windows身份验证来验证客户端凭据

使用这种绑定,效果非常好

<basicHttpBinding>
    <binding>          
      <security mode="TransportCredentialOnly">
        <transport clientCredentialType="Windows" />
      </security>
    </binding>
</basicHttpBinding>
但现在我将使用实体框架和使用这些凭证的可信连接,但它不起作用。 我尝试使用以下代码模拟:

using(OperationContext.Current.ServiceSecurityContext.WindowsIdentity.Impersonate())
{
}
我在哪里失败了?我从8个小时开始就把头撞在墙上。。。
提前感谢。

您的进程可能无权将其模拟委托给其他服务器。如文件所述:

当模拟级别为模拟时,前端和后端服务必须在同一台计算机上运行。当模拟级别为委派时,前端和后端服务可以在单独的计算机上,也可以在同一台计算机上。启用委派级别模拟需要将Windows域策略配置为允许委派


很可能您的管理员没有启用委派域策略。

当您测试WCF客户端和WCF服务器是否在同一台物理计算机上或不同的计算机上时,请注意,您的数据库服务器与WCF服务器在不同的计算机上吗?我使用WCF测试客户端和远程数据库服务器,所以是同一台计算机主机客户端和服务器
using(OperationContext.Current.ServiceSecurityContext.WindowsIdentity.Impersonate())
{
}