Friday, October 14, 2011 5:52 PM
I am attempting to use the Sharepoint QueryService (_vti_bin/search.asmx) installed on server hosted in our organization. I have created the service proxy in my Visual Studio 2005 solution and wrote the C# code to communicate with the QueryService. When I make a simple call, I receive the error "Attempted to perform an unauthorized operation". I have verified that the IIS virtual directory settings on the Sharepoint service app is set as Anonymous Authentication = Disabled and Windows Authentication = Enabled. My proxy call code looks like this:
SearchService.QueryService _service = new ConsoleApplication1.SearchService.QueryService();
_service.UseDefaultCredentials = true;
string _xml = _service.Status();
Help is greatly appreciated. Thank you.
- Moved by Razi bin RaisMicrosoft Employee Monday, October 17, 2011 2:39 AM Programming question (From:SharePoint 2010 - General Questions and Answers)
Monday, October 17, 2011 2:06 AM
Thanks for your post.
When you call the web service, you should set the Credentials property in your code.
// Create a QueryService object.
QueryService.QueryService queryService = new QueryService.QueryService();
// Set authentication credentials.
NetworkCredential networkCredential =
queryService.Credentials = networkCredential;
if you will call the web service in another SharePoint, you have to set the “URL” property for the web service.
Monday, October 17, 2011 4:42 PMThanks. I gave it a try, but same error. I am pretty sure it's a Sharepoint installation/configuration issue, because my code works when I point to a different installation of Sharepoint 2010 running on a different server.
Monday, October 24, 2011 4:25 PMThe problem turned out to be very basic. Permissions were not granted to "authenticated user" in any of the Sharepoint permission groups. Once I added "authenticated user" to the Viewers group, everything worked perfectly.
- Marked As Answer by Wayne Fan Tuesday, October 25, 2011 1:31 AM
Wednesday, October 10, 2012 6:15 PMMy fix is to add the user to the viewers group.