Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 xp_cmdshell rights on the fly

Author  Topic 

skillile
Posting Yak Master

208 Posts

Posted - 2002-06-06 : 10:28:20
I would like to run xp_cmdshell on remote servers but I am running
into access issues. Is there a way to set a user (grant) on the fly
then (revoke) after completion?

ie.

create proc
as

xp_cmdshell dir blah... with this user

xp_cmdshell dir blah... with another user


Thanks

slow down to move faster...

M.E.
Aged Yak Warrior

539 Posts

Posted - 2002-06-06 : 10:53:37
Can't test this one right now, no access to a machine with SQL, but...

Create a role that has the rights run the XP_cmdshell on the remote machine. Inside your stored Proc, use sp_addrolemember and sp_droprollmember to add and remove the user to this roll.

Heh, I'm probably somewhere out in left field with this one though... I need beer



------

Heres when I edit my post with arrows pointing downward telling you to read setbased's answer... it makes a little more sense



Edited by - M.E. on 06/06/2002 11:02:03
Go to Top of Page

setbasedisthetruepath
Used SQL Salesman

992 Posts

Posted - 2002-06-06 : 10:55:46
You're better off writing a procedure on the remote server that makes the specific xp_cmdshell call you need, rather than having the caller go direct to xp_cmdshell. Then you won't need to grant/revoke.

setBasedIsTheTruepath
<O>
Go to Top of Page
   

- Advertisement -