Pages

Friday, October 19, 2012

search.asmx web service : Server was unable to process request. ---> Attempted to perform an unauthorized operation



I was getting "Server was unable to process request. ---> Attempted to perform an unauthorized operation" error while accessing SharePoint 2010 OOTB search web service from C# windows application. I have very simple code which is calling search web service and returning data in grid format. I have refer this MSDN link for sample code: http://msdn.microsoft.com/en-us/library/ff394650.aspx 

I have searched a lot in Google and also spent good amount of time but didn't get success from any of the sites and didn’t find any resolution.

Finally I have found very interesting root cause for my problem and resolved the issue by myself :)

Here is the actual issue: When we are adding ‘service reference’ from visual studio tool, system is removing actual full site name from the site address URL and keeping just the top level site name into app.config file for service end point address.

e.g. I have added http://sptoplevelsite.com/sites/subsitename/_vti_bin/search.asmx as service reference from Visual Studio, but app.config file has http://sptoplevelsite.com/_vti_bin/search.asmx as service end point address instead of exact full site URL.

So in my case, most of the user doesn’t have access to top level SharePoint URL because of which I was getting "Server was unable to process request. ---> Attempted to perform an unauthorized operation." Error.

Solution:
1) I have just added user to the top level site http://sptoplevelsite.com and same code started working without making any changes into code or server level configuration.
2) I need to find a way to change or pass end point address from C# code itself which will overwrite app.config file settings.

Sometime small things matter :)

Enjoy!!!!

No comments:

Post a Comment