Today I've faced an issue while accessing SharePoint web services to achieve certain integration needs between my application and SharePoint site.
The integration way is design to use SharePoint web services as the main way to access SharePoint data.
I’ve write a small code snippet to query a document library and retrieve its folder and subfolders recursively and it works great on my SharePoint development environment but when trying it on another SharePoint environment it doesn’t work and always through access denied although I have passed all the necessary credentials to the web service object whatever I’m doing I’m always get
E_ACCESSDENIED Server was unable to process request. ---> Access is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED))
After comparing between my development environment and the other environment I’ve discovered that my application is using classic mode (Windows authentication mode) while the other environment is using Claim based mode (mixed mode).
Below are the recommended solution to access the SharePoint 2010 web services regarding to the authentication mechanism the application configured:
1- Extend your application to use Windows Authentication only
Extend your mixed authentication web application, and create a zone just for Windows Authentication, then change the Web Reference URL in the properties of your web service, to use that extended URL and port. You should have no issues of this kind anymore, the following article illustrate the steps clearly
The request failed with the error message: Object moved (SharePoint 2010, Web Services & FBA) http://gvaro.wordpress.com/2011/01/04/the-request-failed-with-the-error-message-object-moved-sharepoint-2010-web-services-fba/
2- Add the following code snippet to the generated reference file.
You must add an additional header to your request. The header name must be X-FORMS_BASED_AUTH_ACCEPTED and the value must be f. Adding that header will tells SharePoint to use Windows authentication.
Edit your generated reference and append the following method
protected override System.Net.WebRequest GetWebRequest(Uri uri)
System.Net.WebRequest wr = null;
wr = base.GetWebRequest(uri);
catch (Exception ex)
//Some error handling goes here.
A good reference at MSDN: Retrieving Data from a Multi-Authentication Site Using the Client Object Model and Web Services in SharePoint 2010 http://msdn.microsoft.com/en-us/library/hh124553.aspx#Y1200