我有一个使用WCF的Silverlight应用程序。我希望能够根据正在使用该应用程序的Windows用户获得独特的信息;即,我想仅显示该用户的数据。该网站将托管在IIS上。我遇到了各种各样的问题...在WCF服务环境中使用唯一的Windows ID
我最初使用的是HttpContext.Current
,但是当我在IIS中托管它时(尽管使用Windows身份验证),它开始回归为空。
我在我的web.config:
<system.web>
<authentication mode="Windows"/>
<system.web>
我想知道的唯一的事情就是Silverlight的clientconfig细节。该绑定有<security mode="None"/>
,但每当我尝试并更改它们时,都会收到错误消息。
我目前使用basicHttpBinding。
我也为我的服务设置了aspNetCompatibility,所以它应该能够处理HttpContext。
这是我的ServiceReferences.ClientConfig文件:
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="winAuthBinding" maxBufferSize="2147483647"
maxReceivedMessageSize="2147483647">
<security mode="TransportWithMessageCredential">
<transport clientCredentialType="Windows" proxyCredentialType="Windows"/>
</security>
</binding>
</basicHttpBinding>
</bindings>
<client>
<endpoint address="../service.svc"
binding="basicHttpBinding" bindingConfiguration="winAuthBinding"
contract="Contract1" name="name1" />
<endpoint address="../service.svc"
binding="basicHttpBinding" bindingConfiguration="winAuthBinding"
contract="Contract2" name="name2" />
<endpoint address="../service.svc"
binding="basicHttpBinding" bindingConfiguration="winAuthBinding"
contract="Contract3" name="name3" />
</client>
</system.serviceModel>
而web.config中;我只贴system.serviceModel部分:
<system.serviceModel>
<behaviors>
<serviceBehaviors>
<behavior name="serviceBehaviour">
<serviceMetadata httpGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="true" />
</behavior>
</serviceBehaviors>
</behaviors>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />
<bindings>
<basicHttpBinding>
<binding name="winAuthBinding">
<security mode="TransportCredentialOnly">
<transport clientCredentialType="Windows"/>
</security>
</binding>
</basicHttpBinding>
</bindings>
<services>
<service behaviorConfiguration="serviceBehaviour" name="name1">
<endpoint address="" binding="basicHttpBinding" bindingConfiguration="winAuthBinding"
contract="Contract1"/>
</service>
<service behaviorConfiguration="serviceBehaviour" name="name2">
<endpoint address="" binding="basicHttpBinding" bindingConfiguration="winAuthBinding"
contract="Contract2"/>
</service>
<service behaviorConfiguration="serviceBehaviour" name="name3">
<endpoint address="" binding="basicHttpBinding" bindingConfiguration="winAuthBinding"
contract="Contract3"/>
</service>
</services>
<client/>
</system.serviceModel>
您是否为IIS中的应用程序启用了Windows身份验证? – faester 2011-05-05 11:17:31
是的。它目前提供有:NTLM,Negotioate(按顺序)和高级设置:关闭扩展保护,启用内核模式保护。 – Harry 2011-05-05 11:23:17
当我启动网站时,我现在正在获取登录框。在禁用匿名身份验证并启用Windows后,现在就会发生这种情况。我如何让它自动化? – Harry 2011-05-05 12:19:42