SharePoint Web Service Reference: Authentication Error

On my newly created virtual machine I started working on a web services project and encountered a problem I almost forgot about. When adding a SharePoint web service reference in Visual Studio I was prompted for my credentials, yet being unable to add the reference. Here is what I’ve done to solve the issue.

Introduction

My setup is as follows:

  • Virtual machine: Windows Server 2003 Standard
  • Host name: vmwin2k3 (no Active Directory involved)
  • HOSTS file entry: 192.168.0.100 dev.vmwin2k3
  • Web Application URL: http://dev.vmwin2k3 (via host headers)

When I tried adding a web service reference in Visual Studio 2008 I was prompted for my credentials:

Being prompted for credentials while adding a SharePoint web service reference

Being prompted for credentials while adding a SharePoint web service reference

Pressing Cancel repeatedly revealed an error that should actually not have come up:

Authentication against the SharePoint web service failed

Authentication against the SharePoint web service failed

The Solution

To remidy the issue I was forced to dig a bit deeper. There exists a knowledge base article (KB896861) over at Microsoft.com. Basically, it describes how a loopback check introduced with Windows Server 2003 SP1 prevents yourself from authenticating against the host when using a FQDN or custom host header:

Windows XP SP2 and Windows Server 2003 SP1 include a loopback check security feature that is designed to help prevent reflection attacks on your computer. Therefore, authentication fails if the FQDN or the custom host header that you use does not match the local computer name.

All we need to do is to fire up regedit and specify a list of host names (host header values) we are using in order to make authentication work properly:

  1. Open the registry editor (regedit.exe)
  2. In Registry Editor, locate and then click the following registry key:
    HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Lsa\MSV1_0
  3. Right-click MSV1_0, point to New, and then click Multi-String Value.
  4. Type BackConnectionHostNames, and then press ENTER.
  5. Right-click BackConnectionHostNames, and then click Modify.
  6. In the Value data box, type the host name or the host names for the sites that are on the local computer, and then click OK.

    registry

  7. Quit Registry Editor, and then restart the IISAdmin service.

Note: it is mandatory to restart the IISAdmin service. An iisreset won’t do it.

Authentication against the SharePoint web service should work like charm.







One Response to “SharePoint Web Service Reference: Authentication Error”

Hi nice post
One question though I am trying to reference the UserGroup.asmx services and call the UserGroup class from the Service Proxy within my class library and I am not able to and everywhere on the net people insist that I use Web Service Reference instead of Service Reference like the one you used to reference your web services. I know it slightly off topic from what you discuss here but you started out exactly the way I did in my app and now I am stuck, where do I find Web Service Reference under the project menu

:(

Sabata Mereeotlhe added these pithy words on Jun 03 09 at 13:08

Leave a Reply

Bad Behavior has blocked 1654 access attempts in the last 7 days.