【问题标题】:Modifying a Silverlight-Enabled WCF service to cooperate using Windows authentication修改启用 Silverlight 的 WCF 服务以使用 Windows 身份验证进行协作
【发布时间】:2009-10-28 12:52:21
【问题描述】:

我有一个 Silverlight 应用程序,并添加了一个启用 Silverlight 的 WCF 服务。我想将其部署为使用 Windows 身份验证的 Intranet 解决方案,无需匿名访问。

开箱即用,WCF 服务将以下设置添加到 web.config:

<system.serviceModel>
  <behaviors>
   <serviceBehaviors>
    <behavior name="WindowsAuthTest.Web.Service1Behavior">
     <serviceMetadata httpGetEnabled="true" />
     <serviceDebug includeExceptionDetailInFaults="false" />
    </behavior>
   </serviceBehaviors>
  </behaviors>
  <bindings>
   <customBinding>
    <binding name="customBinding0">
     <binaryMessageEncoding />
     <httpTransport />
    </binding>
   </customBinding>
  </bindings>
  <serviceHostingEnvironment aspNetCompatibilityEnabled="true" />
  <services>
   <service behaviorConfiguration="WindowsAuthTest.Web.Service1Behavior"
    name="WindowsAuthTest.Web.Service1">
    <endpoint address="" binding="customBinding" bindingConfiguration="customBinding0"
     contract="WindowsAuthTest.Web.Service1" />
    <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
   </service>
  </services>
 </system.serviceModel>

将此服务引用添加到 silverlight 项目时,会将这些设置添加到 ServiceReferences.ClientConfig:

<system.serviceModel>
        <bindings>
            <customBinding>
                <binding name="CustomBinding_Service1">
                    <binaryMessageEncoding />
                    <httpTransport maxReceivedMessageSize="2147483647" maxBufferSize="2147483647" />
                </binding>
            </customBinding>
        </bindings>
        <client>
            <endpoint address="http://localhost:3568/Service1.svc" binding="customBinding"
                bindingConfiguration="CustomBinding_Service1" contract="ServiceReference1.Service1"
                name="CustomBinding_Service1" />
        </client>
    </system.serviceModel>

如何修改这些设置以使其能够与 Windows 身份验证一起使用?是否可行?

【问题讨论】:

标签: silverlight authentication silverlight-3.0 windows-authentication


【解决方案1】:

尝试添加:

安全模式="TransportCredentialOnly

例如

<binding name="BasicHttpBinding_IUserWebService" maxBufferSize="2147483647"
           maxReceivedMessageSize="2147483647">
       <security mode="TransportCredentialOnly" />
</binding>

在 web.config 中我们使用 basicHttpBinding 例如

 <bindings>
      <basicHttpBinding>
        <binding name="customBasicHttpBinding" maxBufferSize="2147483647"
          maxReceivedMessageSize="2147483647">
          <security mode="TransportCredentialOnly">
            <transport clientCredentialType="Windows" proxyCredentialType="None" />
          </security>
        </binding>
      </basicHttpBinding>      
 </bindings>

【讨论】:

    猜你喜欢
    • 2012-11-20
    • 1970-01-01
    • 2013-08-26
    • 2014-07-04
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多