问题
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
sysadminrole. - The SQL Server service logs on as
Network Service. Network Servicehas 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