0
votes

I am trying to set up a web service which is to have a username and password in order to access the service. I am using this link as a guide http://www.codeproject.com/Articles/642997/Generate-username-authentication-based-on-basicHtt

I've hit an area where i cant get around the below error. With my config below i received this error message

The authentication schemes configured on the host ('Anonymous') do not allow those configured on the binding 'BasicHttpBinding' ('Basic'). Please ensure that the SecurityMode is set to Transport or TransportCredentialOnly. Additionally, this may be resolved by changing the authentication schemes for this application through the IIS management tool, through the ServiceHost.Authentication.AuthenticationSchemes property, in the application configuration file at the element, by updating the ClientCredentialType property on the binding, or by adjusting the AuthenticationScheme property on the HttpTransportBindingElement.

My config file is

<configuration>
  <startup>
    <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
  </startup>
<system.serviceModel>
<behaviors>
  <serviceBehaviors>
    <behavior name="customBehavior">
      <serviceMetadata httpGetEnabled="true" httpsGetEnabled="true" />
      <serviceDebug includeExceptionDetailInFaults="true" />
      <serviceCredentials>
        <userNameAuthentication
          userNamePasswordValidationMode="Custom"
          customUserNamePasswordValidatorType="Project.Services.MyService, Project.Services"/>
      </serviceCredentials>
    </behavior>
  </serviceBehaviors>
</behaviors>
<bindings>
  <basicHttpBinding>
    <binding name="MyBasicHttpBinding">
      <security mode="Transport">
        <transport clientCredentialType="Basic" />
      </security>
    </binding>
  </basicHttpBinding>
</bindings>
<services>
  <service behaviorConfiguration="customBehavior" name="Project.Services.MyService">
    <endpoint address=""
      binding="basicHttpBinding" bindingConfiguration="MyBasicHttpBinding"
      contract="Project.Services.Interfaces.ITechnology">
      <identity>
        <dns value="localhost" />
      </identity>
    </endpoint>
    <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
    <host>
      <baseAddresses>
        <add baseAddress="http://localhost/Service/myService.svc" />
      </baseAddresses>
    </host>
  </service>
</services>
  </system.serviceModel>
  <appSettings>
    <add key="userName" value="user1"/>
    <add key="password" value="password"/>
  </appSettings>
</configuration>

The wcf service is to be used with a Windows Phone 8 application. I've read several articles on the error and have set the endpoint address to "" but nothing i've done is working. I've had to go back to the above config as i think i was making too many changes which might just put me on the wrong track.

The service is hosted on my Local IIS (Win 8 64 bit pro + all updates).

Could anyone assist?

1
A Basic rule in WCF when using BasicHttpBinding with userName authentication is that you cannot pass the username/pwd over http as http transfer is clear text. Hence you have to enable transport security which makes it https.Rajesh
Although i agree with your comment the issue i originally had was Windows Phone 8 does not support https username auth - which is why i have to use basicHttpBinding with user/password. Let me know if this is incorrectComputer

1 Answers

1
votes

According to the error, you need to set up IIS to allow "Basic Authentication" on your service.

In IIS management console, select the authentication tab and set allow "Basic Authentication". Also, disable "Anonymous authentication".

If "Basic Authentication" its not there you need to add this role to your IIS. Check how to do it here.