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 6104343
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T13:49:53+00:00 2026-05-23T13:49:53+00:00

I have made a wcf application, and a client. WCF app. have to know

  • 0

I have made a wcf application, and a client. WCF app. have to know what user and password had accessed the service operation. That is what i done:
Server web config:

    <?xml version="1.0"?>
     <configuration>
    <system.serviceModel>
        <bindings>
            <wsHttpBinding>
                <binding name="wsHttpEndpointBinding">
                    <security>
                        <message clientCredentialType="Certificate" />
                    </security>
                </binding>
            </wsHttpBinding>
        </bindings>
        <behaviors>
            <serviceBehaviors>
                <behavior name="Auth">
                    <serviceDebug includeExceptionDetailInFaults="true"/>
                    <serviceMetadata httpGetEnabled="true"/>
                    <serviceCredentials>
                        <clientCertificate>
                            <authentication certificateValidationMode="PeerTrust"/>
                        </clientCertificate>
                        <serviceCertificate findValue="WCfServer"
                        storeLocation="CurrentUser"
                        storeName="My"
                        x509FindType="FindBySubjectName" />
                    </serviceCredentials>
                </behavior>
            </serviceBehaviors>
        </behaviors>
        <services>
            <service behaviorConfiguration="Auth" name="Service">
                <endpoint address="" binding="wsHttpBinding"       bindingConfiguration="wsHttpEndpointBinding" contract="IService"/>
            </service>
        </services>
    </system.serviceModel>
    <system.web>
        <compilation debug="true"/>
    </system.web>
</configuration>

Client config:

     <?xml version="1.0" encoding="utf-8" ?>
      <configuration>
    <system.serviceModel>
        <bindings>
   <wsHttpBinding>
    <binding name="WSHttpBinding_IService" closeTimeout="00:01:00"
     openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
     bypassProxyOnLocal="false" transactionFlow="false" hostNameComparisonMode="StrongWildcard"
     maxBufferPoolSize="524288" maxReceivedMessageSize="65536" messageEncoding="Text"
     textEncoding="utf-8" useDefaultWebProxy="true" allowCookies="false">
     <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
      maxBytesPerRead="4096" maxNameTableCharCount="16384" />
     <reliableSession ordered="true" inactivityTimeout="00:10:00"
      enabled="false" />
     <security mode="Message">
      <transport clientCredentialType="Windows" proxyCredentialType="None"
       realm="" />
      <message clientCredentialType="Certificate" negotiateServiceCredential="true" />
     </security>
    </binding>
   </wsHttpBinding>
  </bindings>
        <behaviors>
            <endpointBehaviors>
                <behavior name="CustomBehavior">
                    <clientCredentials>
                        <clientCertificate findValue="WcfClient" x509FindType="FindBySubjectName" storeLocation="CurrentUser" storeName="My" />
                        <serviceCertificate>
                            <authentication certificateValidationMode="PeerTrust"/>
                        </serviceCertificate>
                    </clientCredentials>
                </behavior>
            </endpointBehaviors>
        </behaviors>
        <client>
            <endpoint address="http://localhost:30341/WCFAuthTest/Service.svc"
             binding="wsHttpBinding" bindingConfiguration="WSHttpBinding_IService"
             contract="Service.IService" name="WSHttpBinding_IService" behaviorConfiguration="CustomBehavior">
                <identity>
                    <dns value="WcfServer" />
                </identity>
            </endpoint>
  </client>
    </system.serviceModel>
</configuration>

How i generated certificates: http://www.codeproject.com/KB/WCF/9StepsWCF.aspx
Service operation:

    public string TestAccess()
{
    return OperationContext.Current.ServiceSecurityContext.PrimaryIdentity.Name;
}

Client:

            ServiceClient client = new ServiceClient();
        client.ClientCredentials.UserName.UserName = "Admin";
        client.ClientCredentials.UserName.Password = "123";
        Console.WriteLine(client.TestAccess());
        Console.ReadLine();

And program must return Admin but it doesn’t:
http://img27.imageshack.us/img27/3104/returnz.png
I know that i have to change the clientCredentialType to UserName, but it gaves me an error

  • 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-05-23T13:49:53+00:00Added an answer on May 23, 2026 at 1:49 pm

    If you want to pass user name and password you must set client credential type to UserName. Setting it to certificate is for using client certificates. Here is some how to article.

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

Sidebar

Related Questions

We have a C# client app that communicates to our C# backend service via
I have a WCF application that requires some app initialization code to fire when
I have a WCF client application that consists of about 5 proxies that all
I have a REST WCF service and a WCF client application for it. My
I have a web service (WCF or ASMX doesn't matter)... I have made a
I have made a little app for signing up for an event. User input
I have a WCF web service that exposes several business methods. I also have
I have made a WCF service(service1.svc) have 2 methods. 1.GetData() 2.ProductDetails(string ProdId) Both returns
I have a typical Silverlight application with a WCF service and I am using
I have a WCF service and a Web application. Web application makes calls to

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.