Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Copy files between servers

Reply
Thread Tools

Copy files between servers

 
 
Chris Strobel
Guest
Posts: n/a
 
      07-26-2004
I have 2 web servers where I need to write a PDF file and need to keep them
in sync. In others words, If the Server1 is getting called to create the
PDF, then it needs to copy the PDF to the other Server2 and visa-versa. The
2 server are running 2003.

It's a form-based authentication (.NET 1.1) site and I'm using IIS 6 native
mode. Both boxes are set to the same workgroup. Since everything is so
locked down now, I'm not sure what's the best way to copy files to another
server from within a VB ASPX page. I've seen some sample impersonation code
but it seems like there would be an easier way.

Thanks,
Chris


 
Reply With Quote
 
 
 
 
Raterus
Guest
Posts: n/a
 
      07-26-2004
File.Copy("\\Server1\share\file.abc", "\\Server2\share\file.abc", true)

But before you can do this, you are going to have to impersonate a valid domain user that can perform this operation. This can be done via web.config using

<identity impersonate="true" userName="DOMAIN\bob" password="mypassword" />

But if you don't want your entire application running as this user (I woudln't), you can impersonate via code with examples from this article (you would need to use second way if you have a specific user that you want to use), or the first article if you are using credentials from the authenticated client.

http://support.microsoft.com/default...b;en-us;306158

Hope this helps,
--Michael

"Chris Strobel" <(E-Mail Removed)> wrote in message news:%(E-Mail Removed)...
> I have 2 web servers where I need to write a PDF file and need to keep them
> in sync. In others words, If the Server1 is getting called to create the
> PDF, then it needs to copy the PDF to the other Server2 and visa-versa. The
> 2 server are running 2003.
>
> It's a form-based authentication (.NET 1.1) site and I'm using IIS 6 native
> mode. Both boxes are set to the same workgroup. Since everything is so
> locked down now, I'm not sure what's the best way to copy files to another
> server from within a VB ASPX page. I've seen some sample impersonation code
> but it seems like there would be an easier way.
>
> Thanks,
> Chris
>
>

 
Reply With Quote
 
 
 
 
Chris Strobel
Guest
Posts: n/a
 
      07-26-2004
Thanks for the reply Michael...

Is there no way to just have each box trust the other or give the
appropriate rights to each dll assembly?

It seems odd with .NET, that to copy a file between web servers I have to
have 40 or so lines of impersonation code.

Thanks,
Chris

"Raterus" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
File.Copy("\\Server1\share\file.abc", "\\Server2\share\file.abc", true)

But before you can do this, you are going to have to impersonate a valid
domain user that can perform this operation. This can be done via
web.config using

<identity impersonate="true" userName="DOMAIN\bob" password="mypassword" />

But if you don't want your entire application running as this user (I
woudln't), you can impersonate via code with examples from this article (you
would need to use second way if you have a specific user that you want to
use), or the first article if you are using credentials from the
authenticated client.

http://support.microsoft.com/default...b;en-us;306158

Hope this helps,
--Michael

"Chris Strobel" <(E-Mail Removed)> wrote in message
news:%(E-Mail Removed)...
> I have 2 web servers where I need to write a PDF file and need to keep

them
> in sync. In others words, If the Server1 is getting called to create the
> PDF, then it needs to copy the PDF to the other Server2 and visa-versa.

The
> 2 server are running 2003.
>
> It's a form-based authentication (.NET 1.1) site and I'm using IIS 6

native
> mode. Both boxes are set to the same workgroup. Since everything is so
> locked down now, I'm not sure what's the best way to copy files to another
> server from within a VB ASPX page. I've seen some sample impersonation

code
> but it seems like there would be an easier way.
>
> Thanks,
> Chris
>
>



 
Reply With Quote
 
Raterus
Guest
Posts: n/a
 
      07-26-2004
You mentioned workgroup? Is there really not a domain in this situation? If that is the case, I don't think you can even use impersonation. How does your IIS server sit inside this workgroup? is it one of these two servers? Have you tried just the file.copy code and see what happens?


"Chris Strobel" <(E-Mail Removed)> wrote in message news:%(E-Mail Removed)...
> Thanks for the reply Michael...
>
> Is there no way to just have each box trust the other or give the
> appropriate rights to each dll assembly?
>
> It seems odd with .NET, that to copy a file between web servers I have to
> have 40 or so lines of impersonation code.
>
> Thanks,
> Chris
>
> "Raterus" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
> File.Copy("\\Server1\share\file.abc", "\\Server2\share\file.abc", true)
>
> But before you can do this, you are going to have to impersonate a valid
> domain user that can perform this operation. This can be done via
> web.config using
>
> <identity impersonate="true" userName="DOMAIN\bob" password="mypassword" />
>
> But if you don't want your entire application running as this user (I
> woudln't), you can impersonate via code with examples from this article (you
> would need to use second way if you have a specific user that you want to
> use), or the first article if you are using credentials from the
> authenticated client.
>
> http://support.microsoft.com/default...b;en-us;306158
>
> Hope this helps,
> --Michael
>
> "Chris Strobel" <(E-Mail Removed)> wrote in message
> news:%(E-Mail Removed)...
> > I have 2 web servers where I need to write a PDF file and need to keep

> them
> > in sync. In others words, If the Server1 is getting called to create the
> > PDF, then it needs to copy the PDF to the other Server2 and visa-versa.

> The
> > 2 server are running 2003.
> >
> > It's a form-based authentication (.NET 1.1) site and I'm using IIS 6

> native
> > mode. Both boxes are set to the same workgroup. Since everything is so
> > locked down now, I'm not sure what's the best way to copy files to another
> > server from within a VB ASPX page. I've seen some sample impersonation

> code
> > but it seems like there would be an easier way.
> >
> > Thanks,
> > Chris
> >
> >

>
>

 
Reply With Quote
 
William F. Robertson, Jr.
Guest
Posts: n/a
 
      07-26-2004
The way we resolved this issue is create a user account on each web server
machine with the passwords manually syncronized. The have the Application
Pool in IIS 6.0 run under that account. Each account having the same
username and password, will enable write access.

Can you not just save this file in one location and have both servers pull
from this one location?

HTH,

bill


"Chris Strobel" <(E-Mail Removed)> wrote in message
news:%(E-Mail Removed)...
> Thanks for the reply Michael...
>
> Is there no way to just have each box trust the other or give the
> appropriate rights to each dll assembly?
>
> It seems odd with .NET, that to copy a file between web servers I have to
> have 40 or so lines of impersonation code.
>
> Thanks,
> Chris
>
> "Raterus" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
> File.Copy("\\Server1\share\file.abc", "\\Server2\share\file.abc", true)
>
> But before you can do this, you are going to have to impersonate a valid
> domain user that can perform this operation. This can be done via
> web.config using
>
> <identity impersonate="true" userName="DOMAIN\bob" password="mypassword"

/>
>
> But if you don't want your entire application running as this user (I
> woudln't), you can impersonate via code with examples from this article

(you
> would need to use second way if you have a specific user that you want to
> use), or the first article if you are using credentials from the
> authenticated client.
>
> http://support.microsoft.com/default...b;en-us;306158
>
> Hope this helps,
> --Michael
>
> "Chris Strobel" <(E-Mail Removed)> wrote in message
> news:%(E-Mail Removed)...
> > I have 2 web servers where I need to write a PDF file and need to keep

> them
> > in sync. In others words, If the Server1 is getting called to create the
> > PDF, then it needs to copy the PDF to the other Server2 and visa-versa.

> The
> > 2 server are running 2003.
> >
> > It's a form-based authentication (.NET 1.1) site and I'm using IIS 6

> native
> > mode. Both boxes are set to the same workgroup. Since everything is so
> > locked down now, I'm not sure what's the best way to copy files to

another
> > server from within a VB ASPX page. I've seen some sample impersonation

> code
> > but it seems like there would be an easier way.
> >
> > Thanks,
> > Chris
> >
> >

>
>



 
Reply With Quote
 
Scott Allen
Guest
Posts: n/a
 
      07-26-2004
As another option In a workgroup, one could create matching accounts
on both servers.

--
Scott
http://www.OdeToCode.com

On Mon, 26 Jul 2004 12:00:26 -0400, "Raterus" <(E-Mail Removed)>
wrote:

>You mentioned workgroup? Is there really not a domain in this situation? If that is the case, I don't think you can even use impersonation. How does your IIS server sit inside this workgroup? is it one of these two servers? Have you tried just the file.copy code and see what happens?
>
>


 
Reply With Quote
 
Chris Strobel
Guest
Posts: n/a
 
      07-26-2004
Both web servers will sit in a DMZ with same workgroup, separate from the
domain. If I try file.copy I get permission errors. I tried having one box
trust the other assembly and get:

Logon failure: unknown user name or bad password.

Thanks,
Chris

"Raterus" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
You mentioned workgroup? Is there really not a domain in this situation?
If that is the case, I don't think you can even use impersonation. How does
your IIS server sit inside this workgroup? is it one of these two servers?
Have you tried just the file.copy code and see what happens?


"Chris Strobel" <(E-Mail Removed)> wrote in message
news:%(E-Mail Removed)...
> Thanks for the reply Michael...
>
> Is there no way to just have each box trust the other or give the
> appropriate rights to each dll assembly?
>
> It seems odd with .NET, that to copy a file between web servers I have to
> have 40 or so lines of impersonation code.
>
> Thanks,
> Chris
>
> "Raterus" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
> File.Copy("\\Server1\share\file.abc", "\\Server2\share\file.abc", true)
>
> But before you can do this, you are going to have to impersonate a valid
> domain user that can perform this operation. This can be done via
> web.config using
>
> <identity impersonate="true" userName="DOMAIN\bob" password="mypassword"

/>
>
> But if you don't want your entire application running as this user (I
> woudln't), you can impersonate via code with examples from this article

(you
> would need to use second way if you have a specific user that you want to
> use), or the first article if you are using credentials from the
> authenticated client.
>
> http://support.microsoft.com/default...b;en-us;306158
>
> Hope this helps,
> --Michael
>
> "Chris Strobel" <(E-Mail Removed)> wrote in message
> news:%(E-Mail Removed)...
> > I have 2 web servers where I need to write a PDF file and need to keep

> them
> > in sync. In others words, If the Server1 is getting called to create the
> > PDF, then it needs to copy the PDF to the other Server2 and visa-versa.

> The
> > 2 server are running 2003.
> >
> > It's a form-based authentication (.NET 1.1) site and I'm using IIS 6

> native
> > mode. Both boxes are set to the same workgroup. Since everything is so
> > locked down now, I'm not sure what's the best way to copy files to

another
> > server from within a VB ASPX page. I've seen some sample impersonation

> code
> > but it seems like there would be an easier way.
> >
> > Thanks,
> > Chris
> >
> >

>
>



 
Reply With Quote
 
Chris Strobel
Guest
Posts: n/a
 
      07-26-2004
Hi Bill,

Wouldn't we have the same permission problem if there was another server
that both Web servers wrote the file to?

I'll try looking at the application pool account.

Thanks,
Chris


"William F. Robertson, Jr." <wfrobertson_at_kpmg_dot_com> wrote in message
news:(E-Mail Removed)...
> The way we resolved this issue is create a user account on each web server
> machine with the passwords manually syncronized. The have the Application
> Pool in IIS 6.0 run under that account. Each account having the same
> username and password, will enable write access.
>
> Can you not just save this file in one location and have both servers pull
> from this one location?
>
> HTH,
>
> bill
>
>
> "Chris Strobel" <(E-Mail Removed)> wrote in message
> news:%(E-Mail Removed)...
> > Thanks for the reply Michael...
> >
> > Is there no way to just have each box trust the other or give the
> > appropriate rights to each dll assembly?
> >
> > It seems odd with .NET, that to copy a file between web servers I have

to
> > have 40 or so lines of impersonation code.
> >
> > Thanks,
> > Chris
> >
> > "Raterus" <(E-Mail Removed)> wrote in message
> > news:(E-Mail Removed)...
> > File.Copy("\\Server1\share\file.abc", "\\Server2\share\file.abc", true)
> >
> > But before you can do this, you are going to have to impersonate a valid
> > domain user that can perform this operation. This can be done via
> > web.config using
> >
> > <identity impersonate="true" userName="DOMAIN\bob" password="mypassword"

> />
> >
> > But if you don't want your entire application running as this user (I
> > woudln't), you can impersonate via code with examples from this article

> (you
> > would need to use second way if you have a specific user that you want

to
> > use), or the first article if you are using credentials from the
> > authenticated client.
> >
> > http://support.microsoft.com/default...b;en-us;306158
> >
> > Hope this helps,
> > --Michael
> >
> > "Chris Strobel" <(E-Mail Removed)> wrote in message
> > news:%(E-Mail Removed)...
> > > I have 2 web servers where I need to write a PDF file and need to keep

> > them
> > > in sync. In others words, If the Server1 is getting called to create

the
> > > PDF, then it needs to copy the PDF to the other Server2 and

visa-versa.
> > The
> > > 2 server are running 2003.
> > >
> > > It's a form-based authentication (.NET 1.1) site and I'm using IIS 6

> > native
> > > mode. Both boxes are set to the same workgroup. Since everything is so
> > > locked down now, I'm not sure what's the best way to copy files to

> another
> > > server from within a VB ASPX page. I've seen some sample impersonation

> > code
> > > but it seems like there would be an easier way.
> > >
> > > Thanks,
> > > Chris
> > >
> > >

> >
> >

>
>



 
Reply With Quote
 
William F. Robertson, Jr.
Guest
Posts: n/a
 
      07-26-2004
Yes, that would be resolved from the application pool identity.

http://msdn.microsoft.com/library/de...olsettings.asp

It was more commentary on keeping two different data stores in two different
locations.

HTH,

bill



"Chris Strobel" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Hi Bill,
>
> Wouldn't we have the same permission problem if there was another server
> that both Web servers wrote the file to?
>
> I'll try looking at the application pool account.
>
> Thanks,
> Chris
>
>
> "William F. Robertson, Jr." <wfrobertson_at_kpmg_dot_com> wrote in message
> news:(E-Mail Removed)...
> > The way we resolved this issue is create a user account on each web

server
> > machine with the passwords manually syncronized. The have the

Application
> > Pool in IIS 6.0 run under that account. Each account having the same
> > username and password, will enable write access.
> >
> > Can you not just save this file in one location and have both servers

pull
> > from this one location?
> >
> > HTH,
> >
> > bill
> >
> >
> > "Chris Strobel" <(E-Mail Removed)> wrote in message
> > news:%(E-Mail Removed)...
> > > Thanks for the reply Michael...
> > >
> > > Is there no way to just have each box trust the other or give the
> > > appropriate rights to each dll assembly?
> > >
> > > It seems odd with .NET, that to copy a file between web servers I have

> to
> > > have 40 or so lines of impersonation code.
> > >
> > > Thanks,
> > > Chris
> > >
> > > "Raterus" <(E-Mail Removed)> wrote in message
> > > news:(E-Mail Removed)...
> > > File.Copy("\\Server1\share\file.abc", "\\Server2\share\file.abc",

true)
> > >
> > > But before you can do this, you are going to have to impersonate a

valid
> > > domain user that can perform this operation. This can be done via
> > > web.config using
> > >
> > > <identity impersonate="true" userName="DOMAIN\bob"

password="mypassword"
> > />
> > >
> > > But if you don't want your entire application running as this user (I
> > > woudln't), you can impersonate via code with examples from this

article
> > (you
> > > would need to use second way if you have a specific user that you want

> to
> > > use), or the first article if you are using credentials from the
> > > authenticated client.
> > >
> > > http://support.microsoft.com/default...b;en-us;306158
> > >
> > > Hope this helps,
> > > --Michael
> > >
> > > "Chris Strobel" <(E-Mail Removed)> wrote in message
> > > news:%(E-Mail Removed)...
> > > > I have 2 web servers where I need to write a PDF file and need to

keep
> > > them
> > > > in sync. In others words, If the Server1 is getting called to create

> the
> > > > PDF, then it needs to copy the PDF to the other Server2 and

> visa-versa.
> > > The
> > > > 2 server are running 2003.
> > > >
> > > > It's a form-based authentication (.NET 1.1) site and I'm using IIS 6
> > > native
> > > > mode. Both boxes are set to the same workgroup. Since everything is

so
> > > > locked down now, I'm not sure what's the best way to copy files to

> > another
> > > > server from within a VB ASPX page. I've seen some sample

impersonation
> > > code
> > > > but it seems like there would be an easier way.
> > > >
> > > > Thanks,
> > > > Chris
> > > >
> > > >
> > >
> > >

> >
> >

>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Copy files between two web servers... Matthew Moran ASP General 1 08-02-2006 11:18 PM
Difference between servers while code is exact copy (in IE) Els HTML 12 07-12-2006 11:25 AM
Implementing dhcp servers and dns servers =?Utf-8?B?ZG91Z2hib3kzMQ==?= MCSE 20 06-23-2006 11:11 PM
33.6% of servers sold in Q4 2005 were Windows servers Au79 Computer Support 0 03-08-2006 07:11 AM



Advertisments