0

We're building some core services in .Net 3.5 and exposing the services via WCF. The services will only be accessed internally (i.e. within the intranet). The services just need to authenticate the calling user's windows credentials and get their AD/functional groups.

The serives need to be exposed using NetTcpBinding and BasicHttpBinding.

What configuration do I need to add to the section for both both binding types? Is it just this:

  <system.serviceModel>
    <services>
      <service name="WCFTest.CalculatorService" behaviorConfiguration="WCFTest.CalculatorBehavior">
        <host>
          <baseAddresses>
            <add baseAddress = "http://localhost:8000/WCFTest/CalculatorService/" />
            <add baseAddress = "net.tcp://localhost:9000/WCFTest/CalculatorService/" />
          </baseAddresses>
        </host>

        <endpoint address ="basicHttpEP" binding="basicHttpBinding" contract="WCFTest.ICalculatorService"/>
        <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>

        <endpoint address ="netTcpEP" binding="netTcpBinding" contract="WCFTest.ICalculatorService"/>
        <endpoint address="mex" binding="mexTcpBinding" contract="IMetadataExchange"/>

      </service>
    </services>
    <behaviors>
      <serviceBehaviors>
        <behavior name="WCFTest.CalculatorBehavior">          
          <serviceAuthorization impersonateCallerForAllOperations="false"  principalPermissionMode="UseWindowsGroups" />
          <serviceCredentials >
            <windowsAuthentication allowAnonymousLogons="false" includeWindowsGroups="true" />
          </serviceCredentials>    
          <serviceMetadata httpGetEnabled="True"/>
          <serviceDebug includeExceptionDetailInFaults="False" />
        </behavior>
      </serviceBehaviors>
    </behaviors>
  </system.serviceModel>

Is that the case? Will this then apply to both my NetTcp and BasicHttp Bindings?

Thanks

4

2 回答 2

1

In Visual Studio 2008 go to Tools -> WCF Service Configuration Editor. Open your config file and edit the settings there.

于 2009-04-02T10:41:11.017 回答
0

不,netTcpBinding 无需配置:默认情况下它使用 Windows 身份验证。对于 basicHttpBinding,您需要在绑定配置中指定您希望的身份验证机制(因为 basicHttpBinding 默认不使用身份验证):

<system.serviceModel>
  <bindings>
    <basicHttpBinding>
      <binding name="DefaultBasicHttpBinding">
        <security mode="TransportCredentialsOnly">
          <transport clientCredentialType="Windows"/>
        </security>
      </binding>
    </basicHttpBinding>
  </bindings>
  <services>
    <service name="WCFTest.CalculatorService" behaviorConfiguration="WCFTest.CalculatorBehavior">
      <host>
        <baseAddresses>
          <add baseAddress="http://localhost:8000/WCFTest/CalculatorService/" />
          <add baseAddress="net.tcp://localhost:9000/WCFTest/CalculatorService/" />
        </baseAddresses>
      </host>
      <endpoint address="basicHttpEP" binding="basicHttpBinding" contract="WCFTest.ICalculatorService"/>
      <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
      <endpoint address="netTcpEP" binding="netTcpBinding" contract="WCFTest.ICalculatorService"/>
      <endpoint address="mex" binding="mexTcpBinding" contract="IMetadataExchange"/>
    </service>
  </services>
  <behaviors>
    <serviceBehaviors>
      <behavior name="WCFTest.CalculatorBehavior">          
        <serviceMetadata httpGetEnabled="True"/>
        <serviceDebug includeExceptionDetailInFaults="False"/>
      </behavior>
    </serviceBehaviors>
  </behaviors>
</system.serviceModel>
于 2013-10-07T20:15:20.693 回答