How to access a network share folder?

  • Thread starter Thread starter Andrew Shitov
  • Start date Start date
A

Andrew Shitov

I have to copy files from one network share folder to another (both are
on different remote machines). Server running this asp.net appllication
is not configurable (except web.config), while network forlers requires
passwords.

The ideal solution would allow me to simply write File.Copy (from, to,
true).

I thought of two possibilities: either map a network folder inside the
asp.net application or connect to the server that contail share.

Trying to start 'net use' failed:

System.Diagnostics.Process.Start ("net", @"use q: \\server\share$
/user:name password");

After this I still have the same drives as before calling 'net use'.

What should I do? How to map a network drive? Or how to access a server
(not changing the machine.config)?
 
Have you tried using impersonate in the config file to make the application
impersonate a user on the other server, there by giving you permission to
write to the share
 
Have you tried using impersonate in the config file to make the application
impersonate a user on the other server, there by giving you permission to
write to the share

I inserted <identity impersonate="true"/> into web.config - but I have
to somehow pass userName/password pair. If I will place

userName="..." password="..."

into <identity impersonate/> then an application fails to start.
 
You need to grant asp.net account special rights to run exes. If you can't
change anything on the server, you might want to setup remote machines that
host shared directories to allow access to asp.net account on the web
server.

I cannot change remote machine security settings while I am able to
congigure a machine with asp.net application. But is it possible to
aviod modifying machine.config?

How to grant asp.net account these rights?
 
You need to grant asp.net account special rights to run exes. If you can't
change anything on the server, you might want to setup remote machines that
host shared directories to allow access to asp.net account on the web
server.

Eliyahu
 
I am able to act as an administrator of a machine with asp.net
application. Would you tell, how to do that?
 
Here is exactly how i had it working in my application

<configuration>
<system.web>
<identity impersonate="true" userName="DMN\UserName"
password="password" />
</system.web>
</configuration>
 
<system.web>
<identity impersonate="true" userName="DMN\UserName"
password="password" />
</system.web>
</configuration>

In this case an application cannot even start:

Parser Error Message: Could not create Windows user token from the
credentials specified in the config file. Error from the operating
system 'Logon failure: unknown user name or bad password. '

An application need these userName/password only to access the remote
server but it tries to use them even when I open an .aspx page.
 
What you are able to do with your application depends on what rights the
account your application is running under has. Granting rights to accounts
is a job of the system administrator. He/she does it with standard Windows
utilities. It can't be done from within the application.

Eliyahu
 
have you tried to give the user your impersonating, rights to work on the
machine the application is running.

I.E. create a generic user for both servers, enable it admin rights on both
servers, and test if the application will start then?
 
Back
Top