Windows WCF Authentication Error

I am trying to use a Service with a WCF console application. But the only response I get is, "The remote server returned an unexpected response: (400) Bad request."

The service is configured with the following parameters:

<services>
  <service name="TryOut.BasicService" behaviorConfiguration="NicksBasicBehavior">
    <host>
      <baseAddresses>
        <add baseAddress="http://192.168.10.67:8000/Service" />
      </baseAddresses>
    </host>

    <endpoint address ="http://192.168.10.67:8000/Service"

              name="NicksEndpoint"
              binding="basicHttpBinding"
              contract="TryOut.IBasicService"
              bindingConfiguration="BasicBinding"
              />
  </service>
</services>

<behaviors>
  <serviceBehaviors>
    <behavior name="NicksBasicBehavior">       
      <serviceMetadata httpGetEnabled="true"/>
    </behavior>
  </serviceBehaviors>
</behaviors>

<binding name="BasicBinding">
    <security mode="TransportCredentialOnly">
        <transport clientCredentialType="Windows"/>
    </security>
</binding>

      

My Client's config file is as follows:

<system.serviceModel>
<bindings>
  <basicHttpBinding>
    <binding name="NicksEndpoint" closeTimeout="00:01:00" openTimeout="00:01:00"
        receiveTimeout="00:10:00" sendTimeout="00:01:00" allowCookies="false"
        bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
        maxBufferSize="65536" maxBufferPoolSize="524288" maxReceivedMessageSize="65536"
        messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered"
        useDefaultWebProxy="true">
      <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
          maxBytesPerRead="4096" maxNameTableCharCount="16384" />
      <security mode="TransportCredentialOnly">
        <transport clientCredentialType="Windows" proxyCredentialType="None"
            realm="" />
        <message clientCredentialType="UserName" algorithmSuite="Default" />
      </security>
    </binding>
  </basicHttpBinding>
</bindings>
<client>
  <endpoint address="http://192.168.10.67:8000/Service" binding="basicHttpBinding"
      bindingConfiguration="NicksEndpoint" contract="ServiceReference1.IBasicService"
      name="NicksEndpoint" />
</client>

      

Now everything works fine when I run the client on the same PC as the service. But if I try to run the client on a computer that is not in the domain of the PC's server, then I get an error even though I provide login information in the client code:

c.ClientCredentials.Windows.ClientCredential = new System.Net.NetworkCredential("Nick", "password", "mydomain");

      

Has anyone figured out what I am doing wrong and how I can fix this? Thank you pending!

0


a source to share


2 answers


According to this article on MSDN , it looks like you need to specify your credentials in a different way:

WCFTestService.Service myService = new WCFTestService.Service();
myService.Credentials = System.Net.CredentialCache.DefaultCredentials;
MessageBox.Show(myService.GetData(123, true));
myService.Dispose();

      



Could you try this code and try to pass Windows credentials to myService.Credentials

? It works?

Mark

0


a source


Have you tried specifying the UsernamePrincipalName in the identity on your tenant endpoint?



0


a source







All Articles