2009-09-29 69 views
0

我有以下問題。在我的機器我有一個SL 3應用程序,基本上包括:Silverlight 3 + WCF和IIS基本認證

* Client app (SL) 
* Web app (.Net 3.5) 
* Communication with the database handled by WCF 

該網站上我的IIS託管,用下面的驗證設置:

* Anonymous access: off 
* Basic authentication: on 
* Integrated Windows authentication: on 

我的綁定設置爲如下:

<?xml version="1.0" encoding="utf-8"?> 
<configuration> 
    <system.serviceModel> 
     <bindings> 
      <basicHttpBinding> 
       <binding name="BasicHttpBinding_IWcfPortal" maxBufferSize="2147483647" maxReceivedMessageSize="2147483647"> 
        <security mode="TransportCredentialOnly" /> 
       </binding> 
      </basicHttpBinding> 
     </bindings> 
     <client> 
      <endpoint address="http://localhost/MyApp/WCFPortal.svc" binding="basicHttpBinding" 
       bindingConfiguration="BasicHttpBinding_IWcfPortal" contract="WcfPortal.IWcfPortal" 
       name="BasicHttpBinding_IWcfPortal" /> 
     </client> 
    </system.serviceModel> 
</configuration> 

Web.config文件:

<authentication mode="Windows" /> 
    <identity impersonate="true" /> 

當我導航到我的網站時,系統提示輸入用戶名和密碼。如果填寫正確,我可以訪問該站點,但數據庫通信不起作用。當我轉到localhost/MyApp/WcfPortal.svc時,出現以下錯誤:

此服務的安全設置需要「匿名」身份驗證,但未啓用承載此服務的IIS應用程序。

我試着在basicHttpBinding中加入<transport clientCredentialType="Windows" />來安全,但是VS給了我警告「'clientCredentialType'屬性沒有聲明。」

如果有人能幫助我,我將非常感激。

回答

1

我解決了我的問題。原來我不得不改變basicHttpBinding的在兩個地方:ServiceReferences.ClientConfig和程序Web.Config

ServiceReferences.ClientConfig:

<?xml version="1.0" encoding="utf-8"?> 
<configuration> 
    <system.serviceModel> 
    <bindings> 
     <basicHttpBinding> 
     <binding name="BasicHttpBinding_IWcfPortal" maxBufferSize="2147483647" 
      maxReceivedMessageSize="2147483647"> 
      <security mode="TransportCredentialOnly" /> 
     </binding> 
     </basicHttpBinding> 
    </bindings> 
    <client> 
     <endpoint address="http://localhost/MyApp/WCFPortal.svc" binding="basicHttpBinding" 
      bindingConfiguration="BasicHttpBinding_IWcfPortal" contract="WcfPortal.IWcfPortal" 
      name="BasicHttpBinding_IWcfPortal" /> 
    </client> 
    </system.serviceModel> 
</configuration> 

Web.config文件:

...

<authentication mode="Windows" /> 
... 

    <bindings> 
     <basicHttpBinding> 
     <binding name="BasicHttpBinding_IWcfPortal" maxBufferSize="10000000" maxReceivedMessageSize="10000000" receiveTimeout="00:10:00" sendTimeout="00:10:00" openTimeout="00:10:00" closeTimeout="00:10:00"> 
      <security mode="TransportCredentialOnly"> 
       <transport clientCredentialType="Ntlm" /> 
      </security> 
      <readerQuotas maxBytesPerRead="10000000" maxArrayLength="10000000" maxStringContentLength="10000000"/> 
     </binding> 
     </basicHttpBinding> 
    </bindings> 
0

不幸的是,要在IIS6下託管此服務,您必須啓用匿名身份驗證。