May 18, 2021 at 10:34 am
Hello,
I have a problem with "xp_subdirs" inside a stored procedure that always has worked in the past with sql2012 (it's been a long time I used this SP). This is the command:
EXEC master..xp_subdirs '\\<LAN_IP>\dir\';
error: Msg 22006, Level 16, State 1, Line 2
xp_subdirs could not access '\\<LAN_IP>\dir\*.*': FindFirstFile() returned error 58, 'The specified server cannot perform the requested operation.'
This one works fine:
EXEC master..xp_subdirs 'c:\';
I guess this is a problem with rights, but I don't think I configured something special in the past.
Can anyone put me in the right direction?
May 19, 2021 at 11:10 am
Thanks for posting your issue and hopefully someone will answer soon.
This is an automated bump to increase visibility of your question.
May 27, 2021 at 6:58 pm
xp_subdirs is an undocumented procedure, so direct use of it is unsupported. If I review xp_cmdshell documentation I see this note that probably applies to xp_subdirs:
"The Windows process spawned by xp_cmdshell has the same security rights as the SQL Server service account." ref: https://docs.microsoft.com/en-us/sql/relational-databases/system-stored-procedures/xp-cmdshell-transact-sql?view=sql-server-ver15#remarks
The SQL Server service account needs permissions on the target. If running under a Virtual Service Account (the default) then the Machine account will need the permissions (MYSERVER$).
Hope this works out.
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply