Copy files between servers

Discussion in 'ASP .Net' started by Chris Strobel, Jul 26, 2004.

  1. 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
    Chris Strobel, Jul 26, 2004
    #1
    1. Advertising

  2. Chris Strobel

    Raterus Guest

    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.aspx?scid=kb;en-us;306158

    Hope this helps,
    --Michael

    "Chris Strobel" <> wrote in message news:%...
    > 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
    >
    >
    Raterus, Jul 26, 2004
    #2
    1. Advertising

  3. 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" <> wrote in message
    news:...
    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.aspx?scid=kb;en-us;306158

    Hope this helps,
    --Michael

    "Chris Strobel" <> wrote in message
    news:%...
    > 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
    >
    >
    Chris Strobel, Jul 26, 2004
    #3
  4. Chris Strobel

    Raterus Guest

    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" <> wrote in message news:%...
    > 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" <> wrote in message
    > news:...
    > 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.aspx?scid=kb;en-us;306158
    >
    > Hope this helps,
    > --Michael
    >
    > "Chris Strobel" <> wrote in message
    > news:%...
    > > 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
    > >
    > >

    >
    >
    Raterus, Jul 26, 2004
    #4
  5. 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" <> wrote in message
    news:%...
    > 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" <> wrote in message
    > news:...
    > 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.aspx?scid=kb;en-us;306158
    >
    > Hope this helps,
    > --Michael
    >
    > "Chris Strobel" <> wrote in message
    > news:%...
    > > 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
    > >
    > >

    >
    >
    William F. Robertson, Jr., Jul 26, 2004
    #5
  6. Chris Strobel

    Scott Allen Guest

    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" <>
    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?
    >
    >
    Scott Allen, Jul 26, 2004
    #6
  7. 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" <> wrote in message
    news:...
    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" <> wrote in message
    news:%...
    > 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" <> wrote in message
    > news:...
    > 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.aspx?scid=kb;en-us;306158
    >
    > Hope this helps,
    > --Michael
    >
    > "Chris Strobel" <> wrote in message
    > news:%...
    > > 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
    > >
    > >

    >
    >
    Chris Strobel, Jul 26, 2004
    #7
  8. 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:...
    > 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" <> wrote in message
    > news:%...
    > > 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" <> wrote in message
    > > news:...
    > > 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.aspx?scid=kb;en-us;306158
    > >
    > > Hope this helps,
    > > --Michael
    > >
    > > "Chris Strobel" <> wrote in message
    > > news:%...
    > > > 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
    > > >
    > > >

    > >
    > >

    >
    >
    Chris Strobel, Jul 26, 2004
    #8
  9. Yes, that would be resolved from the application pool identity.

    http://msdn.microsoft.com/library/d...html/cpconidentityapplicationpoolsettings.asp

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

    HTH,

    bill



    "Chris Strobel" <> wrote in message
    news:...
    > 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:...
    > > 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" <> wrote in message
    > > news:%...
    > > > 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" <> wrote in message
    > > > news:...
    > > > 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.aspx?scid=kb;en-us;306158
    > > >
    > > > Hope this helps,
    > > > --Michael
    > > >
    > > > "Chris Strobel" <> wrote in message
    > > > news:%...
    > > > > 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
    > > > >
    > > > >
    > > >
    > > >

    > >
    > >

    >
    >
    William F. Robertson, Jr., Jul 26, 2004
    #9
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Steve Richter
    Replies:
    4
    Views:
    5,439
    Steve Richter
    Apr 18, 2005
  2. Els
    Replies:
    12
    Views:
    537
  3. Alex
    Replies:
    2
    Views:
    1,205
  4. Replies:
    26
    Views:
    2,094
    Roland Pibinger
    Sep 1, 2006
  5. Matthew Moran

    Copy files between two web servers...

    Matthew Moran, Aug 2, 2006, in forum: ASP General
    Replies:
    1
    Views:
    147
    Steven Burn
    Aug 3, 2006
Loading...

Share This Page