2011-04-04 66 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