3

The WCF is deployed as a windows service in the server. And the client is a windows form applicaiton. When the client is interacting with the WCF server, is there any kind of authentication going on here?

I got how to resolve this here

I want to know what is the default security mode for NetTCP in WCF? I had nothing related with security in my config file as below. So what is the default?

<system.serviceModel>
    <serviceHostingEnvironment aspNetCompatibilityEnabled="true" />
    <behaviors>
        <serviceBehaviors>
            <behavior name="BasicServiceBehavior">
                <serviceMetadata httpGetEnabled="false"/>
                <serviceDebug includeExceptionDetailInFaults="false"/>
                <dataContractSerializer maxItemsInObjectGraph="2147483647"/>
            </behavior>
        </serviceBehaviors>
        <endpointBehaviors>
            <behavior name="HCCNetTcpBinding" >
                <dataContractSerializer maxItemsInObjectGraph="2147483647"/>
            </behavior>
        </endpointBehaviors>
    </behaviors>
    <services>
        <service behaviorConfiguration="BasicServiceBehavior" name="HCC.SMS4.SERVICES.BASIC.MainServices">
            <endpoint address="" binding="netTcpBinding" contract="HCC.SMS4.SERVICES.BASIC.IMainServices" bindingConfiguration="HCCNetTcpBinding" />
            <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
            <host>
                <baseAddresses>
                    <add baseAddress="http://xxxx:44008/HCsmsBasicServices/"/>
                    <add baseAddress="net.tcp://xxxx:45008/HCsmsBasicServices/"/>
                </baseAddresses>
            </host>
        </service>
    </services>

    <bindings>
        <netTcpBinding>
            <binding name="HCCNetTcpBinding" maxConnections="1000" maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647" maxBufferSize="2147483647"
                      openTimeout="14:00:00" receiveTimeout="14:00:00" sendTimeout="14:00:00">
                <readerQuotas maxDepth="32" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647"/>
            </binding>
        </netTcpBinding>
    </bindings>

</system.serviceModel>
Robin Sun
  • 1,352
  • 3
  • 20
  • 45

3 Answers3

2

The transport security mode of the NetTcpBinding is Transport and the ClientCredentialType is Windows. This is equivalent to the following settings.

<netTcpBinding>
  <binding name="netTcp">
    <security mode="Transport">
      <transport clientCredentialType="Windows" />
    </security>
  </binding>
</netTcpBinding>

So when you use the client proxy class to call the service, you could refer to the following code.

ServiceReference1.ServiceClient client = new ServiceReference1.ServiceClient();
            client.ClientCredentials.Windows.ClientCredential.UserName = "administrator";
            client.ClientCredentials.Windows.ClientCredential.Password = "abcd1234!";
var result = client.SayHello();

https://learn.microsoft.com/en-us/dotnet/framework/wcf/system-provided-bindings https://learn.microsoft.com/zh-cn/dotnet/framework/wcf/feature-details/bindings-and-security

Feel free to contact me if you have any questions.

Abraham Qian
  • 7,117
  • 1
  • 8
  • 22
  • Thanks. This can explain why the client user gets exception that the server has rejected the client credentials in my company. Windows team help us find that the user are disabled in the active directory for some reason. Then the user gets that exception. – Robin Sun Nov 02 '18 at 02:51
1

WCF, its default authentication is Windows if there is none config about it.

0

Per Microsoft documentation for NetTcpBinding the default security is TLS with Windows security.

fanuc_bob
  • 857
  • 1
  • 7
  • 20