2011-10-07 38 views
1

嗨,獲取WindowsAccount爲發出請求到WCF服務

我有一個WCF服務(會話)同時使用WindowsAuthentication和常規用戶名/密碼認證當前用戶。

現在我需要獲取客戶端上發送請求到WCF服務的當前用戶。

我知道這可以在IAuthorizationPolicy中完成,但林不知道如何在webmethod中做到這一點?

我已經試過這樣:

WindowsIdentity.GetCurrent(); 

這並不然而,僅返回運行WCF服務(似乎),而不是已經配有當前requst客戶端用戶當前的用戶?

普萊斯建議

BestRegards

回答

1

ServiceSecurityContext.Current.WindowsIdentity應該做的伎倆。

1

發送請求是avaialable在WCF通過AuthorizationContext用戶的身份,

AuthorizationContext背景= ServiceSecurityContext.Current.AuthorizationContext

,對於任何一種身份驗證方法,不管工作您使用Windows或用戶名/密碼。

默認情況下,WCF不會在正在運行的線程中設置標識,因此您無法使用WindowsIdentity獲取它。

Registers Pablo。