Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8009527
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T18:28:36+00:00 2026-06-04T18:28:36+00:00

I have a WCF service with Net.Tcp binding, my server configuration is <?xml version=1.0

  • 0

I have a WCF service with Net.Tcp binding, my server configuration is

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
  <system.serviceModel>
    <behaviors>
      <serviceBehaviors>
        <behavior name="">
          <serviceMetadata httpGetEnabled="true" />
          <serviceDebug httpHelpPageEnabled="true" includeExceptionDetailInFaults="true"/>
          <serviceCredentials>
            <userNameAuthentication userNamePasswordValidationMode="Custom"
                customUserNamePasswordValidatorType="Service.PlainUserNameValidator, Service" />
          </serviceCredentials>
        </behavior>
      </serviceBehaviors>
    </behaviors>
    <services>
      <service name="Service.TestService">
        <endpoint address="" binding="netTcpBinding" contract="Service.ITestService">
          <identity>
            <dns value="localhost" />
          </identity>
        </endpoint>
        <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
        <host>
          <baseAddresses>
            <add baseAddress="net.tcp://localhost:8732/Service/TestService/" />
            <add baseAddress="http://localhost:8001/service/TestServiceMex/" />
          </baseAddresses>
        </host>
      </service>
    </services>
  </system.serviceModel>
</configuration>

In the configuration I turned on customUserNamePasswordValidatorType. The code to start the host is

class Program
{
    static void Main(string[] args)
    {
        using (ServiceHost host = new ServiceHost(typeof(TestService)))
        {
            host.Open();
            Console.WriteLine("The service is ready.");
            Console.WriteLine(String.Format("Metadata is at {0}?WSDL", host.Description.Endpoints[0].Address));
            Console.WriteLine();
            Console.WriteLine("Press <ENTER> to terminate service.");
            Console.WriteLine();
            Console.ReadLine();
        }
    }
}

And my custom username validator class registered in config file is

namespace Service
{
    using System;
    using System.IdentityModel.Selectors;

    public class PlainUserNameValidator : UserNamePasswordValidator
    {
        public override void Validate(string userName, string password)
        {
            Console.WriteLine("Requesting username {0} and password {1}.", userName, password);
        }
    }
}

However the validator never seems to fire while the client is calling.

Any special trick I need to notice to enable customUserNamePasswordValidatorType for Net.Tcp binding?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T18:28:37+00:00Added an answer on June 4, 2026 at 6:28 pm

    Two points:

    You havent included a certificate, you should do so to ensure the integrity of the client’s credentials, set up a temporary one if you have to and add this to your service credentials.

    <serviceCertificate 
              findValue="localhost" 
                x509FindType="FindBySubjectName" 
                storeLocation="CurrentUser" 
                storeName="My" />
    

    You also havent specified any security – for this to work, both client and service endpoints need to enable Username and Password authentication mode on their bindings

    <netTcpBinding>
      <binding name="tcpWithMessageSecurity">
        <security mode="Message" >
          <message clientCredentialType="UserName"/>
        </security>
      </binding> 
    </netTcpBinding>
    

    then

    <endpoint address="" binding="tcpWithMessageSecurity" contract="Service.ITestService">
    

    Then, name your behavior and add it in the above line.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a WCF service with net.tcp binding, hosted on the server as a
I have a wcf service that uses the .net System.AddIns framework to load assemblies
I have a WCF service written in .net 4, and exposed over net.tcp. Any
I have a net.tcp WCF service, and I would like the OS to pick
I have the WCF REST Service target to .NET Framework 4. I am using
I have a WCF web service called by an ASP .Net web site. In
I have an ASP.NET page that calls to a WCF service. This WCF service
I have a working .Net WCF HTTP service. If I put the URL into
I have an asp.net 4 application that hosts a WCF REST service via WebServiceHost...
I have a .NET web service (using asmx...have not upgraded to WCF yet) that

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.