简体   繁体   English

从C#在远程计算机上运行Windows搜索查询时出错

[英]Error running windows search query on remote machine from C#

When I try to execute the following OLEDB command to programmatically query a search index on a remote machine (ALEC-HP) on the same domain I get the following error message 当我尝试执行以下OLEDB命令以编程方式查询同一域上远程计算机(ALEC-HP)上的搜索索引时,出现以下错误消息

Unspecified error: -2147219688(0x80040718) 未指定的错误:-2147219688(0x80040718)

On the local machine the share \\\\ALEC-HP\\Simon.ALEKATEST.000 can be seen OK 在本地计算机上,共享\\\\ALEC-HP\\Simon.ALEKATEST.000可以看到正常

SELECT System.ItemNameDisplay,SYSTEM.ITEMURL,System.DateModified, 
       System.ItemName, System.Search.Rank, System.Keywords,
       System.Search.AutoSummary,System.Search.GatherTime, System.ItemType  
FROM ALEC-HP.SystemIndex 
WHERE Scope='file://ALEC-HP/Simon.ALEKATEST.000'
AND CONTAINS(*,'"April Dwyer"',1033)

If the query is simplified to 如果查询简化为

SELECT  System.ItemNameDisplay,SYSTEM.ITEMURL,System.DateModified,
        System.ItemName, System.Search.Rank, System.Keywords, 
        System.Search.AutoSummary,System.Search.GatherTime, System.ItemType  
FROM ALEC-HP.SystemIndex 
WHERE CONTAINS(*,'"April Dwyer"',1033)

The same error occurs. 发生相同的错误。

The query on the local index 查询本地索引

SELECT  System.ItemNameDisplay,SYSTEM.ITEMURL,System.DateModified, 
        System.ItemName, System.Search.Rank, System.Keywords,
        System.Search.AutoSummary,System.Search.GatherTime, System.ItemType 
FROM "SYSTEMINDEX" 
WHERE CONTAINS(*,'"April Dwyer"',1033)

runs OK. 运行正常。 Rebuilding the search index on ALEC-HP doesn't help. 在ALEC-HP上重建搜索索引没有帮助。

The remote machine ALEC-HP runs Windows 7 and local search works OK on that machine. 远程计算机ALEC-HP运行Windows 7,并且本地搜索在该计算机上工作正常。

  • Using a remote machine running Win 8.1 the remote index query runs OK. 使用运行Win 8.1的远程计算机,远程索引查询运行正常。
  • I can't see any significant differences in permissions in the Search Index folders (C:\\Program Data\\Microsoft\\Search) on a remote machine where the query runs and a remote machine where it doesn't. 我在运行查询的远程计算机和未运行查询的远程计算机上的“搜索索引”文件夹(C:\\ Program Data \\ Microsoft \\ Search)中看不到权限方面的任何显着差异。
  • The Win 8.1 remote machine does not seem to have a search index folder C:\\Program Data\\Microsoft\\Search\\Data\\Applications\\Windows\\Projects\\SystemIndex\\Indexer\\CiFiles containing .ci files which is present on the Win 7 machine. Win 8.1远程计算机似乎没有包含Windows 7上包含.ci文件的搜索索引文件夹C:\\ Program Data \\ Microsoft \\ Search \\ Data \\ Applications \\ Windows \\ Projects \\ SystemIndex \\ Indexer \\ CiFiles。
  • I think these are database files for the edb database (Jet Blue) used by Windows Search Indexer. 我认为这些是Windows搜索索引器使用的edb数据库(Jet Blue)的数据库文件。
  • The local machine runs Windows 8.1. 本地计算机运行Windows 8.1。

Problem has now appeared on the search index of a remote machine running Win 8.1 现在,在运行Win 8.1的远程计算机的搜索索引上出现了问题

For queries on a remote machine, the scope='File:UNCPath' clause must contain a UNC Path which is shared with the local machine (the path can use either forward or back slashes). 对于在远程计算机上的查询, scope='File:UNCPath'子句必须包含与本地计算机共享的UNC路径(该路径可以使用正斜杠或反斜杠)。 Ie: 即:

AND SCOPE='file://server/shareName'

If the path is not visible to the local machine, or the scope absent then the Unspecified Error appears. 如果该路径对本地计算机不可见,或者该范围不存在,则出现“未指定错误”。 A more informative error message would be helpful! 更详尽的错误消息会有所帮助!

ps Accessibility of the UNC Path from the local machine is not the whole story. ps UNC路径从本地计算机的可访问性不是全部。 On the remote machine the search location list includes the My Documents folders in two profile folders folder, which are both shared and have the same permissions for SYSTEM, which is the account used to run remote search. 在远程计算机上,搜索位置列表包括两个配置文件文件夹文件夹中的“我的文档”文件夹,这两个文件夹是共享的,并且对SYSTEM(运行远程搜索的帐户)具有相同的权限。 The share permissions are the same, but when one of the profile folders is used in the scope parameter, the Undefined Error appears. 共享权限是相同的,但是在scope参数中使用了一个配置文件文件夹时,将出现“未定义错误”。 Search functions as expected for the other profile folder. 搜索功能与其他配置文件文件夹一样。

The error code 0x80040718 can be found in WindowsSearchErrors.h . 错误代码0x80040718可以在WindowsSearchErrors.h找到。 It corresponds to: 它对应于:

QRY_E_INVALIDSCOPES
The scopes specified for the query were incorrectly formatted.

If you want to search the local catalog of another computer you must : 如果要搜索另一台计算机的本地目录,则必须

  • prefix the server name before the catalog 在目录之前为服务器名称添加前缀
  • provide a valid UNC share in the SCOPE 在范围内提供有效的UNC份额

From MSDN: SCOPE and DIRECTORY Predicates 从MSDN: 范围和目录谓词

To query the local catalog of a remote computer, include the computer name before the catalog and a Universal Naming Convention (UNC) path on the remote computer in the SCOPE or DIRECTORY clause. 若要查询远程计算机的本地目录,请在目录之前添加计算机名称,并在SCOPE或DIRECTORY子句中包括远程计算机上的通用命名约定(UNC)路径。

You can find more information in Querying Process in Windows Search 您可以在Windows搜索的查询过程中找到更多信息。

Local and Remote Queries 本地和远程查询

You can execute your queries either locally or remotely. 您可以在本地或远程执行查询。 A local query using the FROM clause is shown in the following example. 以下示例显示了使用FROM子句的本地查询。 A local query queries the local SystemIndex catalog only. 本地查询仅查询本地SystemIndex目录。

 FROM SystemIndex 

A remote query using the FROM clause is shown in the following example. 以下示例显示了使用FROM子句的远程查询。 Adding ComputerName transforms the previous example into a remote query. 添加ComputerName将前面的示例转换为远程查询。

 FROM [<ComputerName>.]SystemIndex 

To retrieve an item by remote query, the item must meet the following requirements: 要通过远程查询检索项目,该项目必须满足以下要求:

  • Be accessible via Universal Naming Convention (UNC) path. 可通过通用命名约定(UNC)路径访问。
  • Exist on the remote computer to which the client has access. 存在于客户端可以访问的远程计算机上。
  • Have its security set to allow the client to have Read access. 设置其安全性以允许客户端具有读取访问权限。

After you share the folder(s), you can query the local index by specifying the remote computer's machine name in the FROM clause, and a UNC path on the remote computer in the SCOPE clause. 共享文件夹后,可以通过在FROM子句中指定远程计算机的计算机名称,并在SCOPE子句中指定远程计算机的UNC路径来查询本地索引。 A remote query using the FROM and SCOPE clauses is shown in the following example. 以下示例显示了使用FROM和SCOPE子句的远程查询。

 SELECT System.ItemName FROM MachineName.SystemIndex WHERE SCOPE='file://MachineName/<path>' 

And the page URL Formatting Requirements documents some other variations for SQL for remote queries: URL格式要求 ”页面记录了用于远程查询的SQL的其他一些变体:

  • Local : file:///c:\\test\\example\\ 本地file:///c:\\test\\example\\
  • Local : file:c:/test/example/ 本地的file:c:/test/example/
  • Local : c:\\test\\example\\ 本地c:\\test\\example\\
  • Remote : file:///\\\\server\\share\\ 远程file:///\\\\server\\share\\
  • Remote : file://server/share/ 远程file://server/share/
  • Remote : \\\\server\\share\\ 远程\\\\server\\share\\

This means that: 这意味着:

  • your query must add server name in two places 您的查询必须在两个位置添加服务器名称
  • the UNC in the SCOPE or DIRECTORY must be a valid share on the remote machine SCOPE或DIRECTORY中的UNC必须是远程计算机上的有效共享

For example: 例如:

SELECT System.ItemNameDisplay
FROM "ALEC-HP".SystemIndex
WHERE SCOPE='file://ALEC-HP/Simon.ALEKATEST.000'

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 从 Linux c# 获取在远程 Windows 机器上运行的进程 - Get a process running on remote windows machine from Linux c# 如何使用C#/ vb从远程计算机启动Windows 10上的远程注册表服务 - How to start remote registry services on windows 10 from a remote machine using c#/vb Windows搜索查询C# - Windows Search query c# 如何使用C#将文件从远程Windows计算机复制到另一Windows计算机? - How to copy files from remote windows machines to another windows machine using C#? 使用Web服务器上运行的C#代码在远程计算机上创建目录连接 - Creating a Directory Junction on a remote machine from c# code running on a web server 用于在Windows应用程序中连接到远程计算机的模拟(C#) - Impersonation for connect to remote machine in windows application(c#) 如何使用C#在远程Windows机器上创建共享文件夹? - How to create a shared folder on a remote Windows machine using C#? 在c#中作为Windows服务运行时,TCP / IP套接字不从机器读取数据 - TCP/IP Socket is not reading data from machine when running as Windows Service in c# 在C#中查询正在运行的Windows工作流程 - Query running windows workflows in c# 在Windows XP计算机上运行SlimDX C#应用程序时遇到的麻烦 - troubles with running SlimDX C# application on Windows XP machine
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM