问题描述
我正在尝试使用'EXEC MASTER..XP_CMDSHELL'访问文件夹/目录,它适用于本地文件/文件夹,但是它无法通过网络访问该文件夹.
I am trying to access a folder/directory using 'EXEC MASTER..XP_CMDSHELL' it works for the local file/folder, how ever it can not access the folder over network.
EXEC MASTER..XP_CMDSHELL 'c:\Images' --Works fine
EXEC MASTER..XP_CMDSHELL '\\IPaddress\Images' -- returns "Access is denied."
请注意,我可以访问网络位置,但不能使用sql server.
Please note that i can access the network location but not using sql server.
Sql服务器正在Winodws身份验证模式下运行.SQL服务器正在使用"NT Authority \ Network Service"帐户访问远程文件夹.
Sql server is running under Winodws Authentication mode.Sql server is using 'nt authority\network service' account to access the remote Folder.
致谢
推荐答案
如果运行xp_cmdshell'whoami.exe',它将告诉您该命令在其下运行的帐户.如果此帐户没有网络权限,则会收到您看到的错误.
If you run xp_cmdshell 'whoami.exe' it will tell you the account the command is running under. If this account doesn't have permissions on the network, you'll get the error you are seeing.
检查SQL文档以更改此帐户/权限.
Check the SQL documentation for changing this account/permissions.
这篇关于如何在sql server 2008中通过XP_CMDSHELL通过网络访问文件/文件夹?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!