How to access a network share folder?

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)?
 
G

GrantMagic

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
 
A

Andrew Shitov

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.
 
A

Andrew Shitov

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?
 
E

Eliyahu Goldin

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
 
A

Andrew Shitov

I am able to act as an administrator of a machine with asp.net
application. Would you tell, how to do that?
 
G

GrantMagic

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>
 
A

Andrew Shitov

<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.
 
E

Eliyahu Goldin

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
 
G

GrantMagic

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?
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,767
Messages
2,569,572
Members
45,045
Latest member
DRCM

Latest Threads

Top