WCF,实体框架和模拟
本文关键字:模拟 框架 实体 WCF | 更新日期: 2023-09-27 18:12:17
我正在开发一个使用windows身份验证来验证客户端凭据的WCF服务。
使用这个绑定效果很好
<basicHttpBinding>
<binding>
<security mode="TransportCredentialOnly">
<transport clientCredentialType="Windows" />
</security>
</binding>
</basicHttpBinding>
使用以下服务方法:
[AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Required)]
public class PricesSynchro : IPricesSynchro
{
[OperationBehavior(Impersonation = ImpersonationOption.Required)]
public string Hello()
{
return "Hello " + OperationContext.Current.ServiceSecurityContext.WindowsIdentity.Name;
}
但是现在我将使用实体框架与可信连接使用这些凭证,它不起作用。我尝试使用以下代码进行模拟:
using(OperationContext.Current.ServiceSecurityContext.WindowsIdentity.Impersonate())
{
}
我哪里失败了?8个小时以来,我一直在埋头苦干……
您的进程可能没有授权将其模拟委托给另一个服务器。如下所示:
当模拟级别为impersonation时,前端和后端服务必须在同一台机器上运行。当模拟级别为Delegation时,前端和后端服务可以位于单独的机器上,也可以位于同一台机器上。启用委托级模拟需要将Windows域策略配置为允许委托。
很可能您的管理员没有启用委托域策略