WCF service, legacy client using Basic authentication?

Discussion in 'ASP .Net Security' started by Jeff Stephens, Jun 2, 2009.

  1. I am trying to develop a WCF service hosted in IIS that will be called by a
    Windows Mobile client. Because the client is using the Compact Framework, it
    appears I won't be able to use either WCF or WSE in the client. The web
    service will require authentication. I am therefore trying to use Basic
    Authentication over HTTPS.

    I have a simple WCF service, and a WCF client that works great. But for the
    life of me, I can't get a simple web service client that works. I am using
    VS 2008, the client project is targeted for .NET 2.0, and added a standard
    web reference. I am supplying credentials to the proxy as follows:

    proxy.Credentials = new System.Net.NetworkCredential(@"MyUserName",
    "MyPassword", "MyDomain");

    The config file for my service is as follows:

    <system.serviceModel>
    <bindings>
    <basicHttpBinding>
    <binding name="BasicAuthenticationConfiguration">
    <security mode="Transport">
    <transport clientCredentialType="Basic"/>
    </security>
    </binding>
    </basicHttpBinding>
    </bindings>
    <services>
    <service name="CalculatorService.Service"
    behaviorConfiguration="CalculatorServiceBehavior">
    <host>
    <baseAddresses>
    <add baseAddress="https://MyServer/CalculatorService/Service.svc" />
    </baseAddresses>
    </host>
    <endpoint
    name="BasicAuthenticationEndpoint"
    address=""
    binding="basicHttpBinding"
    bindingConfiguration="BasicAuthenticationConfiguration"
    contract="CalculatorService.ICalculator" />
    <endpoint address="mex" binding="mexHttpBinding"
    contract="IMetadataExchange" />
    </service>
    </services>
    <behaviors>
    <serviceBehaviors>
    <behavior name="CalculatorServiceBehavior">
    <serviceMetadata httpGetEnabled="true"/>
    <serviceDebug includeExceptionDetailInFaults="true"/>
    </behavior>
    </serviceBehaviors>
    </behaviors>
    </system.serviceModel>

    The response I get is:

    System.Net.WebException: The request failed with HTTP status 401:
    Unauthorized.

    Oddly enough, if I omit the Domain parameter from the NetworkCredential
    constructor, and instead use "MyDomain\MyUserName" in the UserName parameter,
    I get a "401: Access Denied." response instead of "Unauthorized".

    I'm sure that the credentials I'm using are valid (and indeed the same
    credentials work just fine in the WCF client). It seems to make no
    difference whether I use basicHttpBinding or wsHttpBinding.

    What am I doing wrong? Any suggestions, thoughts, speculation or advice
    would be very welcome at this point!
     
    Jeff Stephens, Jun 2, 2009
    #1
    1. Advertising

  2. Of course, as soon as I post this, I get it working. The solutions was to
    disable "Integrated Windows authentication" in IIS. Why that would do the
    trick, when I'm passing a Windows domain login, I don't understand. But at
    least the client works now.
     
    Jeff Stephens, Jun 2, 2009
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Simon
    Replies:
    0
    Views:
    1,038
    Simon
    Oct 13, 2009
  2. Cindy Lee
    Replies:
    1
    Views:
    2,182
    Mr. Arnold
    Mar 19, 2010
  3. Curt K
    Replies:
    3
    Views:
    468
    John Saunders [MVP]
    Jun 15, 2007
  4. Eddie
    Replies:
    0
    Views:
    936
    Eddie
    Jan 29, 2009
  5. Markus Leder

    WCF client passing 2 client authentication tokens?

    Markus Leder, Apr 14, 2010, in forum: ASP .Net Web Services
    Replies:
    1
    Views:
    1,150
    Mr. Arnold
    Apr 14, 2010
Loading...

Share This Page