PC Review


Reply
Thread Tools Rate Thread

Copy files over WAN?

 
 
glbdev@gmail.com
Guest
Posts: n/a
 
      24th Jan 2008
Hi.

I have an application which is copying files from one location to
another using UNC paths. This is working fine right now using a local
machine but it will soon be moved to a WAN and I am wondering what
type, if any, problems I may have in doing this.

Does anyone have any experience with this and what can I expect or do
to eliminate any potential problems.

Thanks in advance

Steve
 
Reply With Quote
 
 
 
 
Eliyahu Goldin
Guest
Posts: n/a
 
      24th Jan 2008
You will have to take care of security. You may want to impersonate the
asp.net working process as a user with network rights.

--
Eliyahu Goldin,
Software Developer
Microsoft MVP [ASP.NET]
http://msmvps.com/blogs/egoldin


<(E-Mail Removed)> wrote in message
news:f7140c5b-76e9-49bb-a849-(E-Mail Removed)...
> Hi.
>
> I have an application which is copying files from one location to
> another using UNC paths. This is working fine right now using a local
> machine but it will soon be moved to a WAN and I am wondering what
> type, if any, problems I may have in doing this.
>
> Does anyone have any experience with this and what can I expect or do
> to eliminate any potential problems.
>
> Thanks in advance
>
> Steve


 
Reply With Quote
 
George Ter-Saakov
Guest
Posts: n/a
 
      24th Jan 2008
The problem (and the only one) is security.

I assume that you coping file from ASP.NET hence under local ASP.NET account
your pages running under.
So you either allow access read/write to those folders to "everyone"
account.
Or you you will have to go there (to those shared folders) using different
accounts.

Here is how to do that. I am reading file from protected share folder into
byte array into this example.
#region WIN API Declarations

//used in calling WNetAddConnection2

[StructLayout(LayoutKind.Sequential)]

public struct NETRESOURCE

{

public int dwScope;

public int dwType;

public int dwDisplayType;

public int dwUsage;

[MarshalAs(UnmanagedType.LPStr)]

public string lpLocalName;

[MarshalAs(UnmanagedType.LPStr)]

public string lpRemoteName;

[MarshalAs(UnmanagedType.LPStr)]

public string lpComment;

[MarshalAs(UnmanagedType.LPStr)]

public string lpProvider;

}

//WIN32API - WNetAddConnection2

[DllImport("mpr.dll",

CharSet = System.Runtime.InteropServices.CharSet.Auto)]

private static extern int WNetAddConnection2A(

[MarshalAs(UnmanagedType.LPArray)] NETRESOURCE[] lpNetResource,

[MarshalAs(UnmanagedType.LPStr)] string lpPassword,

[MarshalAs(UnmanagedType.LPStr)] string lpUserName,

int dwFlags);

[DllImport("mpr.dll",

CharSet = System.Runtime.InteropServices.CharSet.Auto)]

private static extern int WNetCancelConnection2A(

[MarshalAs(UnmanagedType.LPStr)] string lpName,

int dwFlags, int fForce);

#endregion

private byte[] GetFSMSFile(string sFile)

{

NETRESOURCE[] nr = new NETRESOURCE[1];

nr[0].lpRemoteName = _sFSMSShare;

nr[0].lpLocalName = ""; //mLocalName;

nr[0].dwType = 1; //disk

nr[0].dwDisplayType = 0;

nr[0].dwScope = 0;

nr[0].dwUsage = 0;

nr[0].lpComment = "";

nr[0].lpProvider = "";

int iErr = WNetAddConnection2A(nr, _sFSMSShareUserPassword, _sFSMSShareUser,
0);

if (iErr > 0)

throw new Exception("Can not connect to FSMS share folder");

FileStream st = null;

try

{

st = new FileStream(_sFSMSShare + "\\" + sFile, FileMode.Open);

int iLen = (int)st.Length;

byte []b = new byte[iLen];

st.Read(b, 0, iLen);

return b;

}

finally

{

if( st != null )

st.Close();

WNetCancelConnection2A(_sFSMSShare, 0, -1);

}

}

}




<(E-Mail Removed)> wrote in message
news:f7140c5b-76e9-49bb-a849-(E-Mail Removed)...
> Hi.
>
> I have an application which is copying files from one location to
> another using UNC paths. This is working fine right now using a local
> machine but it will soon be moved to a WAN and I am wondering what
> type, if any, problems I may have in doing this.
>
> Does anyone have any experience with this and what can I expect or do
> to eliminate any potential problems.
>
> Thanks in advance
>
> Steve



 
Reply With Quote
 
glbdev@gmail.com
Guest
Posts: n/a
 
      24th Jan 2008
On Jan 24, 1:17*pm, "Eliyahu Goldin"
<REMOVEALLCAPITALSeEgGoldD...@mMvVpPsS.org> wrote:
> You will have to take care of security. You may want to impersonate the
> asp.net working process as a user with network rights.
>
> --
> Eliyahu Goldin,
> Software Developer
> Microsoft MVP [ASP.NET]http://msmvps.com/blogs/egoldin
>
> <glb...@gmail.com> wrote in message
>
> news:f7140c5b-76e9-49bb-a849-(E-Mail Removed)...
>
>
>
> > Hi.

>
> > I have an application which is copying files from one location to
> > another using UNC paths. *This is working fine right now using a local
> > machine but it will soon be moved to a WAN and I am wondering what
> > type, if any, problems I may have in doing this.

>
> > Does anyone have any experience with this and what can I expect or do
> > to eliminate any potential problems.

>
> > Thanks in advance

>
> > Steve- Hide quoted text -

>
> - Show quoted text -


Thanks Eliyahu, I have thought of this and appreciate the input.

Steve
 
Reply With Quote
 
glbdev@gmail.com
Guest
Posts: n/a
 
      24th Jan 2008
On Jan 24, 1:24*pm, "George Ter-Saakov" <gt-...@cardone.com> wrote:
> The problem (and the only one) is security.
>
> I assume that you coping file from ASP.NET hence under local ASP.NET account
> your *pages running under.
> So you either allow access read/write to those folders to "everyone"
> account.
> Or you you will have to go there (to those shared folders) using different
> accounts.
>
> Here is how to do that. I am reading file from protected share folder into
> byte array into this example.
> #region WIN API Declarations
>
> //used in calling WNetAddConnection2
>
> [StructLayout(LayoutKind.Sequential)]
>
> public struct NETRESOURCE
>
> {
>
> public int dwScope;
>
> public int dwType;
>
> public int dwDisplayType;
>
> public int dwUsage;
>
> [MarshalAs(UnmanagedType.LPStr)]
>
> public string lpLocalName;
>
> [MarshalAs(UnmanagedType.LPStr)]
>
> public string lpRemoteName;
>
> [MarshalAs(UnmanagedType.LPStr)]
>
> public string lpComment;
>
> [MarshalAs(UnmanagedType.LPStr)]
>
> public string lpProvider;
>
> }
>
> //WIN32API - WNetAddConnection2
>
> [DllImport("mpr.dll",
>
> CharSet = System.Runtime.InteropServices.CharSet.Auto)]
>
> private static extern int WNetAddConnection2A(
>
> [MarshalAs(UnmanagedType.LPArray)] NETRESOURCE[] lpNetResource,
>
> [MarshalAs(UnmanagedType.LPStr)] string lpPassword,
>
> [MarshalAs(UnmanagedType.LPStr)] string lpUserName,
>
> int dwFlags);
>
> [DllImport("mpr.dll",
>
> CharSet = System.Runtime.InteropServices.CharSet.Auto)]
>
> private static extern int WNetCancelConnection2A(
>
> [MarshalAs(UnmanagedType.LPStr)] string lpName,
>
> int dwFlags, int fForce);
>
> #endregion
>
> private byte[] GetFSMSFile(string sFile)
>
> {
>
> NETRESOURCE[] nr = new NETRESOURCE[1];
>
> nr[0].lpRemoteName = _sFSMSShare;
>
> nr[0].lpLocalName = ""; //mLocalName;
>
> nr[0].dwType = 1; //disk
>
> nr[0].dwDisplayType = 0;
>
> nr[0].dwScope = 0;
>
> nr[0].dwUsage = 0;
>
> nr[0].lpComment = "";
>
> nr[0].lpProvider = "";
>
> int iErr = WNetAddConnection2A(nr, _sFSMSShareUserPassword, _sFSMSShareUser,
> 0);
>
> if (iErr > 0)
>
> throw new Exception("Can not connect to FSMS share folder");
>
> FileStream st = null;
>
> try
>
> {
>
> st = new FileStream(_sFSMSShare + "\\" + sFile, FileMode.Open);
>
> int iLen = (int)st.Length;
>
> byte []b = new byte[iLen];
>
> st.Read(b, 0, iLen);
>
> return b;
>
> }
>
> finally
>
> {
>
> if( st != null )
>
> st.Close();
>
> WNetCancelConnection2A(_sFSMSShare, 0, -1);
>
> }
> }
> }
> <glb...@gmail.com> wrote in message
>
> news:f7140c5b-76e9-49bb-a849-(E-Mail Removed)...
>
>
>
> > Hi.

>
> > I have an application which is copying files from one location to
> > another using UNC paths. *This is working fine right now using a local
> > machine but it will soon be moved to a WAN and I am wondering what
> > type, if any, problems I may have in doing this.

>
> > Does anyone have any experience with this and what can I expect or do
> > to eliminate any potential problems.

>
> > Thanks in advance

>
> > Steve- Hide quoted text -

>
> - Show quoted text -


Thanks George. I will keep this code for when we do the move. I
really appreciate the fast response I recieved to this request!!

Steve
 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

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
I am looking for a file copy program that will simply copy files without stopping LarryB Windows XP 6 8th Mar 2007 08:24 PM
Reinstalled 2nd copy of WindowsXP but now cant read files from 1st Copy Carey Frisch [MVP] Microsoft Access 4 13th Jun 2005 08:47 PM
using File.Copy to copy files to shared hosting site Steve Richter Microsoft ASP .NET 4 18th Apr 2005 04:06 PM
Still unable to copy files to CD-R using WinXP copy feature GJP Windows XP New Users 7 16th Oct 2004 06:43 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 08:28 AM.