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
 Transact-SQL (2000)
 Running a SP with different credentials?

Author  Topic 

Mmats
Starting Member

47 Posts

Posted - 2005-07-08 : 12:06:53
I want to be able to run an xp_cmdshell to copy a file from one place to another, however I need the rights of a certain user for access to the file. Is there a way to run the stored proc using credentials of the user and password I provide to it?

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2005-07-08 : 13:26:13
No. You'll need to contact the DBA of that SQL Server to copy the file. He/she can do something for you that has to do with a proxy account. Check SQL Server Books Online for more details on it.

Tara
Go to Top of Page

Kristen
Test

22859 Posts

Posted - 2005-07-08 : 13:33:51
If you can set up your Sproc as a scheduled job it will run with the SQL System Account - and if that has the necessary permissions Bingo!

Kristen
Go to Top of Page

Mmats
Starting Member

47 Posts

Posted - 2005-07-08 : 13:42:06
quote:
Originally posted by Kristen

If you can set up your Sproc as a scheduled job it will run with the SQL System Account - and if that has the necessary permissions Bingo!

Kristen




Actually that is the problem, I am logged into sql as admin but I need to have rights of a certain windows account to access the file.
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2005-07-08 : 13:46:40
Then you can do it by mapping a drive on the SQL Server. When you map a drive, you are able to pass in different credentials for it to use. This can all be done via xp_cmdshell. Once mapped, you can then use xcopy. Just remember to unmap the drive when done so that someone else doesn't have access to it.

Tara
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2005-07-08 : 13:53:28
Oh and BTW, the DOS command that you'll need is NET USE. Run NET USE /? from a cmd window to see its options.

Tara
Go to Top of Page

Mmats
Starting Member

47 Posts

Posted - 2005-07-08 : 13:57:39
perfect. thanks
Go to Top of Page
   

- Advertisement -