繁体   English   中英

调用ASMX的WCF模拟错误

[英]WCF Impersonation Error Calling ASMX

我有一个Web应用程序,该应用程序根据需要调用具有模拟设置的WCF方法。 在这种方法中,我需要调用另一个返回安全组的Web服务(ASMX)。 问题是,将“模拟”设置为“必需”时,尝试创建ASMX服务的实例时出现错误。

WCF服务方法

[OperationBehavior(Impersonation = ImpersonationOption.Required)]
public List<MacroTypeInfo> GetFilteredMacroDataTypes(MacroDataTypeSection section)
{

    // Errors out here
    using (var login = new local.intranet.webservices.login())
    {
        login.getSecurityGroupsForUser(); // Never gets to this line
    }    

}

我得到的错误是

Either a required impersonation level was not provided, or the provided    
impersonation level is invalid. (Exception from HRESULT: 0x80070542)

为了能够在“模拟所需的方法”内部调用此Web服务,我还必须做其他事情吗? 删除OperationBehavior属性后,该调用即开始工作。

除非获得许可,否则服务器无法将客户端模拟到远程服务器。 您可以在此处阅读有关模拟的不同级别的信息

如果需要这样的模拟客户端必须与模拟级别的明确允许其Delegation

您可以通过以下端点行为配置在WCF客户端中实现此目的:

<endpointBehaviors>
    <behavior name="delegateIdentity">
      <clientCredentials>
        <windows allowedImpersonationLevel="Delegation"/>
      </clientCredentials>
    </behavior>
</endpointBehaviors>

如果您使用的是生成的代理,则可以在代理上设置以下值:

client.ChannelFactory.Credentials.Windows.AllowedImpersonationLevel =
    System.Security.Principal.TokenImpersonationLevel.Delegation;

最后,如果你创建你代理ChannelFactory<T>你可以设置相同的值作为上述对你ChannelFactory<T>

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM