0

I know how to use xp_cmdshell to get a listing of a local directory. The statement below gives me a list of cvs files in the dir C:\TEST. I ran the statement in my locally installed SSMS.

EXEC Master..xp_cmdShell 'dir C:\TEST\*.csv /b'

However,

EXEC Master..xp_cmdShell 'dir \\ip-adress\share\folder\*.csv /b'

returns a 'No access'.

But running dir \\ip-adress\share\folder\*.csv /b in my commandshell does return a listing. Apparantly I as a user have sufficient rights. Then why does xp_cmdShell return a 'access denied' ?

Is xp_cmdSHell unusable with shares or has this to do with the account that issues the command? But if I started SSMS locally, should the command not run locally under my WIndowsaccount? Same as in commandshell?

Henrov
  • 1,610
  • 1
  • 24
  • 52
  • 1
    Presumably the service account that SQL Server is using does *not* have access to the remote path. `xp_cmdshell` runs under the credentials of the service account, not the account you are connected as. – Thom A Jun 01 '21 at 15:28
  • I used a SSIS proxy based on my own credentials but it looks like the machine on which the SQL Server is running, is blocked from accessing that share. – Henrov Jun 02 '21 at 08:50

1 Answers1

0

I used a SSIS proxy based on my own credentials but it looks like the machine on which the SQL Server is running, is blocked from accessing that share

Henrov
  • 1,610
  • 1
  • 24
  • 52