Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

The HTTP request is unauthorized with client authentication scheme 'Negotiate'

1) On Machine A - I have created an WCF service and hosted it IIS 5.1, on MachineA. which is running under this URL http://mydomain/SetupPOCService/Service1.svc

2) On Machine B - I created an Asp.net Web Applciation. In this application I tried to consume the previously created WCF service which is now hosted on another m/c i.e. MachineA. When I run this web application from Visual Studio environment, it access that MachineA's WCF service and get the data.

---Fine till here---

3) On Machine B - Now I hosted My Web Application in IIS5.1 This web application is working fine here but could not able to acces that MachineA's WCF service and giving this kind of error.

The remote server returned an error: (401) Unauthorized.

StackTrace [MessageSecurityException: The HTTP request is unauthorized with client authentication scheme 'Negotiate'. The authentication header received from the server was 'Negotiate,NTLM'.]

I tried so many things but it dint helped. Please give your inputs...

Below is Web.Config for client

 <security mode="TransportCredentialOnly">
  <transport clientCredentialType="Windows" proxyCredentialType="None"
   realm="" />
  <message clientCredentialType="UserName" algorithmSuite="Default" />
 </security>

Below is Web.Config for Server

<behaviors>
  <serviceBehaviors>
    <behavior>
      <serviceMetadata httpGetEnabled="true"/>
      <serviceDebug includeExceptionDetailInFaults="false"/>
 </behavior>
like image 871
user1294938 Avatar asked Mar 27 '12 08:03

user1294938


1 Answers

Go to the IIS. You find something called "basic settings". Add your permissions and the machine's permissions. It may be you are not allowed to access some boundaries in your network.

  • Go to "Start | Settings | Control Panel | Administrative Tools | Local Security Settings".
  • Go to Local Policies | Security Options
  • Select Network Security : Lan Manager Authentication Level
  • Select the 2nd value in the "Drop Down" Send LM & NTLM.........

Also ClientCredentialType=Windows makes the authentication header Negotiate, which isn't quite enough for it to work with Negotiate, NTLM

However, setting client.ClientCredentials.Windows.AllowNTLM = True adds the necessary NTLM to the authentication header, and it works.

Also try running your VS as administrator just in case. :)

like image 145
Milee Avatar answered Oct 15 '22 18:10

Milee