2011-04-04 30 views
0

我想爲我的Silverlight應用程序使用當前的Windows用戶。使用任何其他應用程序,我可以使用WindowsIdentity,但似乎我需要使用WCF與ServiceSecurityContext.Current。我的問題是.Current出現爲null在WCF/Silverlight中使用ServiceSecurityContext.Current 4

顯然這是因爲我使用的傳輸模式。我的問題是,Silverlight不能使用TransportWithMessageCredential顯然沒有它想使用Https。

所以我嘗試使用TransportWithMessageCredential和我的服務開始說它期待Https,但接受Http。

我在網上看了一圈,似乎我需要使用wsHttpBinding(不適用於Silverlight)或某種形式的訪問策略使用Http(看起來不起作用)。

當然有更簡單的方法來做到這一點?

回答

1

我設法做一些事情來解決這個問題:

1)<authentication mode="Windows"/>在web.config文件中的web.config文件

2)<serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />。這裏重要的是aspnetCompatibilityEnabled

3)[AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)]屬性在我的WCF服務類。

4)使用HttpContext.Current.User.Identity as WindowsIdentity來獲取窗口標識。

+0

有沒有可能這樣做aspNetCompatibilityEnabled =「true」 – TheWommies 2013-07-30 22:50:57