none
Problem with IIS hosted service

    Question

  • Hi everyone,

    I have successfully created a service hosted in IIS 6. Everything wok fine with Anonymous access enable. I get the following error when I turn off anonymous access.

    Failed Authenticate TestFacNet Test method TestFacNet.TestServiceAplicationFacNet.Authenticate threw exception: 
    System.ServiceModel.Security.MessageSecurityException: The HTTP request is unauthorized with client authentication scheme 'Anonymous'.
    The authentication header received from the server was 'Negotiate,NTLM'. --->  System.Net.WebException: The remote server returned an error: (401) Unauthorized.. 

    My client code look like this. I'm not using a config file on the client

    EndpointAddress epr = new EndpointAddress("http://localhost/ApplicationFacNetWS/servicesecurite.svc");

    WSHttpBinding binding = new WSHttpBinding();
    binding.Security.Transport.ClientCredentialType =
    HttpClientCredentialType.Ntlm;

    ChannelFactory<IServiceSecurite> serviceFactory = new ChannelFactory<IServiceSecurite>(binding, epr);

    serviceFactory.Credentials.Windows.ClientCredential = new System.Net.NetworkCredential("user","password","domain");

    IServiceSecurite service = serviceFactory.CreateChannel();

    service.CallService()

    Web.config

    <service name="ApplicationFacNet_Implementation.ServiceSecurite">

    <endpoint binding="wsHttpBinding" contract="ApplicationFacNet.IServiceSecurite" />

    </service>

    What should I do to have this code working???

    Thanks for your help.

    Friday, March 03, 2006 9:56 PM

Answers

  • Ok I have found the answer.

    Using basicHttpBinding did it.

     

    BasicHttpBinding binding = new BasicHttpBinding();

    binding.Security.Mode = BasicHttpSecurityMode.TransportCredentialOnly;

    binding.Security.Transport.ClientCredentialType = HttpClientCredentialType.Ntlm;

    Saturday, March 04, 2006 3:15 AM

All replies

  • Ok I have found the answer.

    Using basicHttpBinding did it.

     

    BasicHttpBinding binding = new BasicHttpBinding();

    binding.Security.Mode = BasicHttpSecurityMode.TransportCredentialOnly;

    binding.Security.Transport.ClientCredentialType = HttpClientCredentialType.Ntlm;

    Saturday, March 04, 2006 3:15 AM
  • Hi Martin,

               Thanks for your post and reply. I got the same exception and got it right after implementing what you have given. Thanks for your help!

    Regards, Dhileep

     

    Monday, January 08, 2007 6:02 AM
  •  

    For me the following also needed to be done on the client side

     

    <security mode="TransportCredentialOnly">

    <transport clientCredentialType="Ntlm" />

    </security>

     

    Following post helped

    http://geekswithblogs.net/socasanta/archive/2007/07/06/113725.aspx

     

     

     

     

    Wednesday, August 06, 2008 9:57 PM
  • I found a different problem.  It turns out that I had the wrong user password in IIS for the directory security tab.  I allowed anonymous access, but I had the wrong password.  I also had the password NOT controlled by IIS so when I updated the password locally IIS could not update the password and thus fell behind and ding'd me with the error.
    Monday, August 31, 2009 11:09 PM