SQL Server: xp_fileexist and UNC path permissions

跟風遠走 提交于 2019-12-11 12:04:22

问题


I'm attempting to run an ad hoc query in SQL Server Management Studio that uses the undocumented stored procedure xp_fileexist. I want to test for the existence of files in a subfolder under a network shared folder accessed via a UNC path.

Here's a sqlservercentral post that talks about the execution context of xp_fileexist. From what I can tell I've got all the necessary permissions in place:

  • I'm running SQL Server Management Studio from a domain account that has Full Control of the shared folder and its subfolders.
  • The SQL account is linked to the domain account and has the sysadmin role.
  • The SQL Server service logs on as Network Service.
  • Network Service has Full Control of the shared folder and its subfolders.

I'm concerned that some of these permission settings might be overkill, yet xp_fileexist still cannot see the subfolder contents.

EXEC master.dbo.xp_fileexist '\\servername\sharename\subfolder\filename.txt'
File Exists |File is a Directory |Parent Directory Exists
---------------------------------------------------------
0           |0                   |0

But xp_fileexist does see the shared folder itself.

EXEC master.dbo.xp_fileexist '\\servername\sharename'
File Exists |File is a Directory |Parent Directory Exists
---------------------------------------------------------
0           |1                   |1

Questions:

Why are the shared folder's contents invisible?

And what security settings are actually necessary?

来源:https://stackoverflow.com/questions/12100845/sql-server-xp-fileexist-and-unc-path-permissions

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!