Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion Groups
DB Engine
SQL ServerMSDESQL Server CE
Services
Analysis (Data Mining)Analysis (OLAP)DTSIntegration ServicesNotification ServicesReporting Services
Programming
CLRConnectivitySQLXML
Other Technologies
ClusteringEnglish QueryFull-Text SearchReplicationService Broker
General
Data WarehousingPerformanceSecuritySetupSQL Server ToolsOther SQL Server Topics
DirectoryUser Groups
Related Topics
MS AccessOther DB ProductsMS Server Products.NET DevelopmentVB DevelopmentJava DevelopmentMore Topics ...

SQL Server Forum / General / Security / May 2007

Tip: Looking for answers? Try searching our database.

Run As Command

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Rick - 21 May 2007 17:11 GMT
I need to copy a backup file from server to server in seperate domains.
Unfortunately in my company they do not have trusted connections. So I need
to use a seperate logon for the destination server. I have tried a mapped
drive that is mapped as a valid logon in thatdomain with no luck, I get
"cannot find the drive specified." Is there a way thorugh sql server to run a
job or a copy as something different than the SQL Agent account. FYI, the
logon that I use to logon to the other domain cannot be registered as a logon
to SQL server bacause SQL Server cannot see that domain. Any suggestions?
Sue Hoegemeier - 22 May 2007 02:58 GMT
Not sure of all the details on the mapped drive - you had no
luck where? Can you create a mapped drive and access it from
your domain with a particular login and password?
If you have that, you could execute net use to map a drive
and specify a domain\user and password. Then copy the file
to that mapped drive. Then delete the mapped drive when
done.

-Sue

>I need to copy a backup file from server to server in seperate domains.
>Unfortunately in my company they do not have trusted connections. So I need
[quoted text clipped - 4 lines]
>logon that I use to logon to the other domain cannot be registered as a logon
>to SQL server bacause SQL Server cannot see that domain. Any suggestions?
vt - 22 May 2007 09:05 GMT
Rick

here is how you can do it

SELECT @VCHCOMMAND = 'net use v: \\10.1.97.150\sqlbackups$\SRDEV dbbackup
/user:XXXX\srdev_db_backup'
EXEC @IRESULT = MASTER..XP_CMDSHELL @VCHCOMMAND, NO_OUTPUT

where v: is the share name
dbbackup : password to connect \\10.1.97.150\sqlbackups$\SRDEV
XXXX\srdev_db_backup : is the  user login on the destination server

if you are using BACKUP DATABASE command to backup the database then

issue the above command first and then backup up the database on to v:

hope this helps you

Regards
VT
Knowledge is power, share it....
http://oneplace4sql.blogspot.com/

>I need to copy a backup file from server to server in seperate domains.
> Unfortunately in my company they do not have trusted connections. So I
[quoted text clipped - 7 lines]
> logon
> to SQL server bacause SQL Server cannot see that domain. Any suggestions?
Rick - 24 May 2007 23:02 GMT
This is what I came up with after a lot of trial and error

Declare @VCHCOMMAND Char (150),
    @CMD    Char (50),
    @COPY       Char (50)
Set @VCHCOMMAND = 'net use L: *\\172.9.17.99\Backup peoples123
/user:sigueqa\rpeoples'
Set @COPY = 'copy \\server2\Backup\DB\SIRETGUE.Bak L:\DB'
Set @CMD = @VCHCOMMAND + ' Y ' + @COPY
EXEC MASTER..XP_CMDSHELL @CMD

, but I get the following error:

L: has a remembered connection to \\172.17.9.67\backup. Do you
want to overwrite the remembered connection? (Y/N) [Y]:
No valid response was provided.
NULL

Any Suggestions?

> Rick
>
[quoted text clipped - 30 lines]
> > logon
> > to SQL server bacause SQL Server cannot see that domain. Any suggestions?
Dan Guzman - 25 May 2007 02:42 GMT
> L: has a remembered connection to \\172.17.9.67\backup. Do you
> want to overwrite the remembered connection? (Y/N) [Y]:
> No valid response was provided.
> NULL
>
> Any Suggestions?

First, remove the persistent connection:

EXEC master..xp_cmdshell 'net use L: /delete'

Then try:

--map drive
EXEC master..xp_cmdshell 'net use L: \\172.9.17.99\Backup peoples123
/user:sigueqa\rpeoples /persistent:no'
--copy
EXEC master..xp_cmdshell 'copy \\server2\Backup\DB\SIRETGUE.Bak L:\DB'
--unmap drive
EXEC master..xp_cmdshell 'net use L: /delete'

I might be wrong but I think you could also do without the drive letter:

--establish security credentials
EXEC master..xp_cmdshell 'net use \\172.9.17.99\Backup peoples123
/user:sigueqa\rpeoples /persistent:no'
--copy
EXEC master..xp_cmdshell 'copy \\server2\Backup\DB\SIRETGUE.Bak
\\172.9.17.99\Backup\DB'
--unmap
EXEC master..xp_cmdshell 'net use \\172.9.17.99\Backup /delete'

Signature

Hope this helps.

Dan Guzman
SQL Server MVP

> This is what I came up with after a lot of trial and error
>
[quoted text clipped - 53 lines]
>> > to SQL server bacause SQL Server cannot see that domain. Any
>> > suggestions?
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.