开发者

Sharepoint 2010 search via webservice gives "Attempted to perform an unauthorized operation"

We've set up Sharepoint search (not enterprise though) to index some of our standard asp.net sites and if I go to the search page in sharepoint and search for anything specific I get the results back that I am looking for.

However I am trying to consume the search webservice from a standard website (not in sharepoint) now and getting a "Attempted to perform an unauthorized operation" error. I know I am authenticating properly, since fiddler shows me the 401 and then the 200 response to say that it is OK. However the moment I call .Query (the last line in my code sample) it gives me the error.

This is my code

searchcentre2.QueryService queryService = new 开发者_StackOverflowsearchcentre2.QueryService();
System.Net.NetworkCredential _credentials = new System.Net.NetworkCredential(_username, _password, _domain);
queryService.Credentials = _credentials;
queryService.UseDefaultCredentials = false;
queryService.PreAuthenticate = true;
queryService.Url = _url;
m_lSearchResutls.Text = queryService.Query(queryxml.ToString());

I have tried and currently running all three of the following.

  1. Turning anonymous off everywhere, both my local site and the sharepoint search section.
  2. Setting the credentials with my own, and I am in the site owners and site collection administrators group
  3. Gave my machine name access to the site collection administrators group (as per my sysadmin's advice as the both sites application pool runs under the network service account)

Is there anything else that I need to set or fix or look at? I am running out of ideas of things to try. Is it something on the sharepoint side that I have to set up still?

I have tried both search.asmx/spsearch.asmx and .Query/.QueryEx and there was no difference in the error message above.

There are code samples out there where you use basic authentication by adding it to the header which I have tried but that didnt work either. I've even tried NTLM, however if it was my security I wouldnt have gotton a 401 and then 200 response surely?

So now I am beginning to think that it is something on Sharepoint side that I have to change. But what?

Any help would be appreciated.


It looks like I have fixed my issue. Thank you to Michael O'Donovan at Microsoft for his advise and suggestions.

I am currently using the RSS feed for search, which gives me my description field back. It looks like it also accepts my credentials (though I need to test the search results to make sure I get the right entries back). The url for the Search RSS feed and its querystring parameters is as follows : http://searchsite/_layouts/srchrss.aspx?k=keyword&s=scope&u=&start=1

We are not running Kerberos in our sharepoint environment and this is the cause of our authentication problems to the search.asmx and spsearch.asmx pages. There is a double hop in authentication happening somewhere and kerberos would resolve that issue.

Hope this helps out someone else in the same predicament as me.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜