MOSS 2007 Search Web Service – 401 Unauthorized
I have recently been working on an issue where I was receivieing a 401 unauthorized access when calling the search.asmx web service. The reason why I was getting this error is because anonymous access was enabled for the IIS Web site. The anonymous access of course filters down to the _vti_bin application and eventually to the search.asmx file itself. Anonymous access never crossed my mind for some reason as I was able to access the service description just fine, it only happened when executing the methods, QueryEx method specifically.
I was able to execute a work around for this limitation, which once implemented works as I expected it to work with full anonymous turned on. What I did was configure the search.asmx file itself under the _vti_bin application in the IIS Web site to not allow anonymous access. This still allowed users to anonymously browse my SharePoint site. After testing, I realized the DataFormWebPart I created to execute the call to the QueryEx method worked with an anonymous user even though the search.asmx file was set to not allow anonymous. The results I received in my test were sites enabled for anonymous access, when I clicked the sign in link in the upper right, i received all the sites I had access to.
I also came across this nifty tool called SharePoint Search Service Tool which helps test and build querypackets against the SharePoint 2007 (and WSS v3) search web services:
http://www.codeplex.com/SharePointSearchServ