2
從WCF服務內部我可以確定調用服務的身份驗證方法嗎?WCF端點決定哪個Auth方法調用
例如;
if (Forms Authentication) {
//do something
}
if (WindowsAuthentication) {
//do something else
}
從WCF服務內部我可以確定調用服務的身份驗證方法嗎?WCF端點決定哪個Auth方法調用
例如;
if (Forms Authentication) {
//do something
}
if (WindowsAuthentication) {
//do something else
}
您可以檢查在OperationContext
的ServiceSecurityContext
WCF服務類中,並從,你可以決定用戶如何認證(如果有的話)。現在
ServiceSecurityContext security =
OperationContext.Current.ServiceSecurityContext;
你可能對安全環境的其中之一:
如果您有其他身份驗證機制(如證書或聯合身份驗證),您的PrimaryIdentity
將包含該機制的合適標識。
請參閱Fundamentals of WCF Security(鏈接到第3頁)以獲得對此主題的精彩討論。
絕對的傳說謝謝。我將在早上嘗試第一件事。 (我在格林威治標準時間) –
嘗試使用此,但OperationContext.Current爲空。它需要在某個地方設置嗎? –
@Mike Mengell:你有什麼樣的服務? SOAP還是REST?什麼約束? –