2009-09-29 43 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下托管此服务,您必须启用匿名身份验证。