472,802 Members | 1,212 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,802 software developers and data experts.

Writing to a virtual directory from ASP.NET 2.0: Is there an easy

I have an ASP.NET app that must allow users to upload files. The files are
stored in a virtual directory. I use Server.MapPath to map from the virtual
directory name to a physical path, then the FileUpload control SaveAs method
to upload and save the file.

This all works fine when the virtual directory points to a local drive on
the ASP.NET server. However, when pointing to a remote drive (which is what
my client wants to do), I get errors.

I found another post in this newgroup where someone has the same problem.
The solution posted is :

---------------------------------------
to read/write to a network share require the asp.net account run as a domain
account.
for 2003, turn off impersonation and use an appool with a domain account
with permissions to the share.
for 2000, you need to impersonate a domain/account
----------------------------------------
This is from the thread
https://msdn.microsoft.com/newsgroup...=en-us&m=1&p=1

According to my network guy (I myself am clueless about network
permissions), this is not a trivial solution. I'd rather not make my client
jump through hoops in order to save files to a remote directory. Is there an
alternative way to do this that doesn't involve this level of security? (some
security is good; solutions that require my client to spend a few hours
redoing their security model is not good.) Is there something obvious I'm
missing?

Thanks in advance.
Dec 21 '05 #1
2 2570
This is actually extremely simple. I'm not sure what other considerations
your network guy is taking into account, so it may not be so under your
network's design.

The solution involves changing the user your application is pretending to
be. By default, your application pretends to be ("impersonates") a local
machine user, with minimal permissions. You need to set your application to
impersonate a domain user that has MODIFY permissions on the target
directory. This is a line of code in your web.config for you, and a user
creation and ACL assignment for your network admin (unless there's a
firewall in the way).

When you change your application's impersonation, you can expect all sorts
of things to stop working, because you'll need to set permissions on other
directories as well. Don't woryy--these will be clearly pointed out to you
on all the error pages you'll get. It's not too bad--maybe 4 dirs tops
you'll have to update, depending on what else your app does, and you'll be
fine.

"BLetts" <BL****@discussions.microsoft.com> wrote in message
news:97**********************************@microsof t.com...
I have an ASP.NET app that must allow users to upload files. The files are
stored in a virtual directory. I use Server.MapPath to map from the virtual directory name to a physical path, then the FileUpload control SaveAs method to upload and save the file.

This all works fine when the virtual directory points to a local drive on
the ASP.NET server. However, when pointing to a remote drive (which is what my client wants to do), I get errors.

I found another post in this newgroup where someone has the same problem.
The solution posted is :

---------------------------------------
to read/write to a network share require the asp.net account run as a domain account.
for 2003, turn off impersonation and use an appool with a domain account
with permissions to the share.
for 2000, you need to impersonate a domain/account
----------------------------------------
This is from the thread
https://msdn.microsoft.com/newsgroup...=en-us&m=1&p=1
According to my network guy (I myself am clueless about network
permissions), this is not a trivial solution. I'd rather not make my client jump through hoops in order to save files to a remote directory. Is there an alternative way to do this that doesn't involve this level of security? (some security is good; solutions that require my client to spend a few hours
redoing their security model is not good.) Is there something obvious I'm
missing?

Thanks in advance.

Dec 21 '05 #2
Hello Richard.
Your comments imply impersonation is an all or nothing choice which must be
applied to the entire application.

Isn't it possible to apply impersonation to a given page or perhaps
re-design the application to include a virtual application with its own
web.config which resides under the root of the parent application?

Impersonation could then be applied to this "partitioned" virtual
application which does the file writing activities? I wouldn't know either
way but I'd like to be prepared when this issue becomes partinent to my
project requirements.

<%= Clinton Gallagher

"Richard Dudley" <rj******@gmail.com> wrote in message
news:Oy**************@TK2MSFTNGP15.phx.gbl...
This is actually extremely simple. I'm not sure what other considerations
your network guy is taking into account, so it may not be so under your
network's design.

The solution involves changing the user your application is pretending to
be. By default, your application pretends to be ("impersonates") a local
machine user, with minimal permissions. You need to set your application
to
impersonate a domain user that has MODIFY permissions on the target
directory. This is a line of code in your web.config for you, and a user
creation and ACL assignment for your network admin (unless there's a
firewall in the way).

When you change your application's impersonation, you can expect all sorts
of things to stop working, because you'll need to set permissions on other
directories as well. Don't woryy--these will be clearly pointed out to
you
on all the error pages you'll get. It's not too bad--maybe 4 dirs tops
you'll have to update, depending on what else your app does, and you'll be
fine.

"BLetts" <BL****@discussions.microsoft.com> wrote in message
news:97**********************************@microsof t.com...
I have an ASP.NET app that must allow users to upload files. The files
are
stored in a virtual directory. I use Server.MapPath to map from the

virtual
directory name to a physical path, then the FileUpload control SaveAs

method
to upload and save the file.

This all works fine when the virtual directory points to a local drive on
the ASP.NET server. However, when pointing to a remote drive (which is

what
my client wants to do), I get errors.

I found another post in this newgroup where someone has the same problem.
The solution posted is :

---------------------------------------
to read/write to a network share require the asp.net account run as a

domain
account.
for 2003, turn off impersonation and use an appool with a domain account
with permissions to the share.
for 2000, you need to impersonate a domain/account
----------------------------------------
This is from the thread

https://msdn.microsoft.com/newsgroup...=en-us&m=1&p=1

According to my network guy (I myself am clueless about network
permissions), this is not a trivial solution. I'd rather not make my

client
jump through hoops in order to save files to a remote directory. Is there

an
alternative way to do this that doesn't involve this level of security?

(some
security is good; solutions that require my client to spend a few hours
redoing their security model is not good.) Is there something obvious I'm
missing?

Thanks in advance.


Dec 21 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Jeffry van de Vuurst | last post by:
Hi, (sorry for the crosspost, I wasn't sure which was the best place to put this). I was just thinking about something and wondered if any of you has some ideas about this. I'm using the...
4
by: Michelle | last post by:
I have a website with 6 virtual directories under it who dont "see" the bin/ directory in the root. If I create a /bin directory in each virtual directory and then copy my dll's in there, it...
5
by: Leszek | last post by:
Hello, Could anybody explain what's a difference between a virtual directory and an application root under IIS? I'm a little bit confused. This is mu problem: Let's assume the following...
19
by: Steve Franks | last post by:
I am using VS.NET 2005 beta 2. When I run my project locally using the default ASP.NET Development Web Server it runs using a root address like this: http://localhost:11243/testsite/ However...
4
by: William Sullivan | last post by:
I have an application that pulls images from a physical drive directory, creates a PDF of the image, caches the image, and returns a link to the client (using ajax, but that's not the problem). ...
4
by: Chuck P | last post by:
Using vs05 and making an asp.net 2.0 website. We use VSS and have everything organized like this SolutionName Documents Code WebProjectName1 WebServiceProjectName1
9
by: antonyliu2002 | last post by:
I have a C# class GeneralUtilities.cs , which many of my aspx.cs files will refer to. So, I've put it under the App_Code folder and compiled it to library using csc /target: library from the DOS...
2
by: =?Utf-8?B?UmFq?= | last post by:
I want to get the file names from another virtual directory in IIS, please let me know how can I achieve this.... The web application from which I will be accessing another virtudal directory...
1
by: Developer.Man4 | last post by:
Dear all :) i have a very simple and easy question, is any virtual directory web shared enabled?? if yes, can we conclude that any web enabled folder is a virtual directory and any virtual...
3
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 2 August 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
by: erikbower65 | last post by:
Using CodiumAI's pr-agent is simple and powerful. Follow these steps: 1. Install CodiumAI CLI: Ensure Node.js is installed, then run 'npm install -g codiumai' in the terminal. 2. Connect to...
0
by: kcodez | last post by:
As a H5 game development enthusiast, I recently wrote a very interesting little game - Toy Claw ((http://claw.kjeek.com/))。Here I will summarize and share the development experience here, and hope it...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Sept 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
14
DJRhino1175
by: DJRhino1175 | last post by:
When I run this code I get an error, its Run-time error# 424 Object required...This is my first attempt at doing something like this. I test the entire code and it worked until I added this - If...
0
by: Rina0 | last post by:
I am looking for a Python code to find the longest common subsequence of two strings. I found this blog post that describes the length of longest common subsequence problem and provides a solution in...
0
by: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
0
by: lllomh | last post by:
How does React native implement an English player?
0
by: Mushico | last post by:
How to calculate date of retirement from date of birth

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.