2012-09-04 29 views
1

我在我的WCF服務和代理中使用自定義綁定。我通過從DuplexClientbase繼承來創建代理。 WCF中有一個選項可以幫助我獲取用戶名,誰調用了該方法?有沒有辦法從WCF方法檢索請求的Windows用戶名

這裏是我結合

<bindings> 
    <customBinding> 
     <binding name="CustomPipeBinding" maxConnections="10" openTimeout="01:20:00" receiveTimeout="20.00:00:00" sendTimeout="01:20:00" closeTimeout="01:20:00"> 
      <windowsStreamSecurity protectionLevel="None" /> 
      <namedPipeTransport maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647" maxBufferSize="2147483647" /> 
     </binding> 
     <binding name="CustomTcpBinding" maxConnections="10" openTimeout="01:20:00" receiveTimeout="20.00:00:00" sendTimeout="00:05:00" closeTimeout="01:20:00"> 
      <windowsStreamSecurity protectionLevel="None" /> 
      <reliableSession /> 
      <tcpTransport maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647" maxBufferSize="2147483647"/> 
     </binding> 
    </customBinding> 
</bindings> 

回答

0

您需要您自定義定製綁定來配置你的服務需要模擬爲outlined in this MSDN article.,你需要添加所需的安全元素的配置,讓WCF通過從客戶端到服務的Windows憑證。

在您的服務代碼中,您需要訪問ServiceSecurityContext.Current.WindowsIdentity靜態屬性以獲取所需內容。

+0

謝謝:)我使用ServiceSecurityContext.WindowsIdentity.Name來獲取用戶名。在綁定中,我刪除了protectionLevel =「None」,默認情況下它是EncryptAndSign。 :) – Anuraj

相關問題