开发者

Modifying a Silverlight-Enabled WCF service to cooperate using Windows authentication

I have a Silverlight application, and added a Silverlight-enabled WCF service. I would like to deploy this as an intranet solution using Windows authentication without anonymous access.

Out of the box, the WCF service adds the following settings to the 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>

When adding this service reference to the silverlight proj开发者_C百科ect, these settings are added to the 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>

How do I modify these settings to allow it to work with Windows authentication & is it possible?


Try adding:

security mode="TransportCredentialOnly

e.g.

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

And in the web.config we use basicHttpBinding e.g.

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

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜