Sharepoint 2010 通过网络服务进行搜索时会出现“试图执行未经授权的操作"

问题描述:

我们已经设置了 Sharepoint 搜索(虽然不是企业)来索引我们的一些标准 asp.net 站点,如果我转到 sharepoint 中的搜索页面并搜索任何特定的内容,我会得到我正在寻找的结果.

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.

但是,我现在正在尝试从标准网站(不在 sharepoint 中)使用搜索网络服务并收到尝试执行未经授权的操作"错误.我知道我正在正确地进行身份验证,因为 fiddler 向我展示了 401 和 200 响应,说它没问题.但是,当我调用 .Query(代码示例中的最后一行)时,它给了我错误.

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.

这是我的代码

searchcentre2.QueryService queryService = new searchcentre2.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. 在任何地方都关闭匿名,包括我的本地站点和共享点搜索部分.
  2. 使用我自己的凭据设置凭据,我属于网站所有者和网站集管理员组
  3. 将我的机器名称访问权限授予网站集管理员组(根据我的系统管理员的建议,因为这两个网站应用程序池都在网络服务帐户下运行)

还有什么我需要设置、修复或查看的吗?我已经没有什么可以尝试的想法了.我仍然必须设置共享点方面的某些内容吗?

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?

我已经尝试了 search.asmx/spsearch.asmx 和 .Query/.QueryEx 并且上面的错误消息没有区别.

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

那里有一些代码示例,您可以通过将其添加到我尝试过但也不起作用的标头来使用基本身份验证.我什至尝试过 NTLM,但是如果是我的安全,我肯定不会得到 401 和 200 响应?

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?

所以现在我开始认为我必须改变 Sharepoint 方面的某些事情.但是什么?

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

任何帮助将不胜感激.

看起来我已经解决了我的问题.感谢 Microsoft 的 Michael O'Donovan 的建议和建议.

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

我目前正在使用 RSS 提要进行搜索,这将返回我的描述字段.看起来它也接受我的凭据(尽管我需要测试搜索结果以确保我得到正确的条目).搜索 RSS 提要的 url 及其查询字符串参数如下:http://searchsite/_layouts/srchrss.aspx?k=keyword&s=scope&u=&start=1

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

我们没有在我们的 sharepoint 环境中运行 Kerberos,这是我们对 search.asmx 和 spsearch.asmx 页面的身份验证问题的原因.在某处进行身份验证时会出现双跳,而 kerberos 将解决该问题.

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.