代码之家  ›  专栏  ›  技术社区  ›  user112889

Silverlight 3+WCF和IIS基本身份验证

  •  0
  • user112889  · 技术社区  · 15 年前

    我有以下问题。在我的机器上,我有一个SL 3应用程序,它基本上包括:

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

    该网站托管在my 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>
    

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

    当我导航到我的站点时,系统会提示我输入用户名和密码。填写正确后,我可以访问该网站,但数据库通信不起作用。当我转到localhost/MyApp/WcfPortal.svc时,出现以下错误:

    我试着加上 <transport clientCredentialType="Windows" /> 到basicHttpBinding中的安全性,但VS向我发出警告“未声明'clientCredentialType'属性”。

    如果有人能帮我,我将非常感激。

    2 回复  |  直到 15 年前
        1
  •  1
  •   user112889    15 年前

    我解决了我的问题。结果我不得不在两个地方更改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> 
    
        2
  •  0
  •   Jerry Bullard    15 年前

    不幸的是,要在IIS6下托管此服务,必须启用匿名身份验证。

    推荐文章