我有一个Web应用程序正在根据需要调用带有模拟的WCF方法。在这种方法中,我需要调用返回安全组的另一个Web服务(ASMX)。问题是,在将Impersonation设置为Required的情况下,当我尝试创建ASMX服务的实例时出现错误。WCF模拟错误调用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属性,该调用就起作用。
FWIW你应该**永远不会***使用冒名顶替,因为*任何*原因。 –
你可以扩展这个想法吗? – user3726393
冒充字面上是认证和授权最糟糕的解决方案。即使您希望允许通过Active Directory服务器进行集中管理,您也不应该使用模拟,您应该将API作为API对AD服务器进行身份验证和授权 –