我有一個使用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