簡體   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