how can i access a file/folder over network through XP_CMDSHELL in sql server 2008?

一个人想着一个人 提交于 2020-01-14 22:54:33

问题


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."

Please note that i can access the network location but not using sql server.

Sql server is running under Winodws Authentication mode. Sql server is using 'nt authority\network service' account to access the remote Folder.

Regards


回答1:


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.

Check the SQL documentation for changing this account/permissions.




回答2:


What account is SQL server running under? How do you connect to SQL server? With windows authentication? What do you want "C:\images" to do? Open a folder in explorer? Did you use sp_xp_cmdshell_proxy_account?




回答3:


When you have to put file, like BCP result, or a backup in a remote drive, just map this drive into windows don't work, it must be mapped on SQL Server to!, to do this, try some link like this:

exec xp_cmdshell 'net use p:\ \Server\Folder\Folder\Folder\ /Domain\Login /Password'

Reference : https://social.msdn.microsoft.com/Forums/en-US/6eca2d62-eb86-4f23-9b86-6f917017f50c/bcp-utility-via-xpcmdshell-and-network-drive?forum=sqlsecurity



来源:https://stackoverflow.com/questions/7978297/how-can-i-access-a-file-folder-over-network-through-xp-cmdshell-in-sql-server-20

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