473,320 Members | 1,862 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

File Access via the Web

I have a web app that needs to access a folder on a different server.
The other server "IS" on a domain. I tried using DirectoryInfo, even
with a Virtual Directory, only to find that it pertains to the local
box. Can anyone point me in the direction of being able to access the
file struction on another server?

Thanks
Sep 30 '08 #1
2 1951
"Dave" <Da**********@jacobs.comwrote in message
news:5d**********************************@l62g2000 hse.googlegroups.com...
>I have a web app that needs to access a folder on a different server.
The other server "IS" on a domain. I tried using DirectoryInfo, even
with a Virtual Directory, only to find that it pertains to the local
box. Can anyone point me in the direction of being able to access the
file struction on another server?
The key is using adequate credentials. The web application (which I
assume is an asp.net application since you are asking in a C# group) is
going to be running under the identity of the asp.net worker process, which
is a local account and most likely will not be able to access the folder on
the other server. To override this behaviour, you can add an <identity
impersonate="true" ... /directive to your web.config. You can either
specify a userName and password in this directive, or you can omit it and
asp.net will inherit the identity from IIS (which you can configure as
needed, for instance, you can use integrated authentication to use the
identity of the user that is browsing). Whatever combination you choose, the
final identity that you are using should be granted access permissions to
the folder that you want to browse. Note that if you are going to use
integrated authentication on IIS, and you want that user to access a second
server, there are some requirements that need to be fulfilled from a systems
administration point of view (the server needs to be trusted for
delegation). This is outside of the scope of the questions that can be
answered in a C# forum; if you need to do this, it's better to ask in a
Windows Server forum. See this article:
http://msdn.microsoft.com/en-us/library/ms998351.aspx .

If you don't want to use the asp.net identity as outlined above, an
alternative is to impersonate the user in your code before attempting to
access the remote folder. There are examples on how to do it in MSDN:
http://support.microsoft.com/kb/306158

Once you are using the correct credentials, either System.IO.Directory
(static methods) or DirectoryInfo (instance methods) should be able to
access the remote folder as @"\\server\folder".
Sep 30 '08 #2
Alberto...Excellent Reply! Detailed explanation with references.
Nice!

Thanks

On Sep 30, 1:32*pm, "Alberto Poblacion" <earthling-
quitaestoparacontes...@poblacion.orgwrote:
"Dave" <Dave.Burk...@jacobs.comwrote in message

news:5d**********************************@l62g2000 hse.googlegroups.com...
I have a web app that needs to access a folder on a different server.
The other server "IS" on a domain. *I tried using DirectoryInfo, even
with a Virtual Directory, only to find that it pertains to the local
box. *Can anyone point me in the direction of being able to access the
file struction on another server?

* *The key is using adequate credentials. The web application (which I
assume is an asp.net application since you are asking in a C# group) is
going to be running under the identity of the asp.net worker process, which
is a local account and most likely will not be able to access the folder on
the other server. To override this behaviour, you can add an <identity
impersonate="true" ... /directive to your web.config. You can either
specify a userName and password in this directive, or you can omit it and
asp.net will inherit the identity from IIS (which you can configure as
needed, for instance, you can use integrated authentication to use the
identity of the user that is browsing). Whatever combination you choose, the
final identity that you are using should be granted access permissions to
the folder that you want to browse. Note that if you are going to use
integrated authentication on IIS, and you want that user to access a second
server, there are some requirements that need to be fulfilled from a systems
administration point of view (the server needs to be trusted for
delegation). This is outside of the scope of the questions that can be
answered in a C# forum; if you need to do this, it's better to ask in a
Windows Server forum. See this article:http://msdn.microsoft.com/en-us/library/ms998351.aspx.

* * If you don't want to use the asp.net identity as outlined above, an
alternative is to impersonate the user in your code before attempting to
access the remote folder. There are examples on how to do it in MSDN:
* * *http://support.microsoft.com/kb/306158

* * Once you are using the correct credentials, either System.IO.Directory
(static methods) or DirectoryInfo (instance methods) should be able to
access the remote folder as @"\\server\folder".
Oct 2 '08 #3

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

Similar topics

18
by: Dino | last post by:
dear all, i've created an application for a customer where the customer can upload ..csv-files into a specified ftp-directory. on the server, a php-script, triggered by a cronjob, reads all the...
2
by: Fran Tirimo | last post by:
I am developing a small website using ASP scripts to format data retrieved from an Access database. It will run on a Windows 2003 server supporting FrontPage extensions 2002 hosted by the company...
3
by: Joe Costa | last post by:
I have written the following code to search for the right file depending on the startup file for "Client Access". The menu database that I made will load the correct config file specific for each...
4
by: Bill | last post by:
I need help closing a CMD window when it is executed from Access. 1) The batch file is called from Access. 2) Access closes, 3) the batch runs a copy of the access database (creating a backup)...
1
by: raydelex | last post by:
I am new to securing a database with logins. My questions is: I want only one database to use a new Workgroup file that I have created, not all the Access databases that I bring up under my...
11
by: sur | last post by:
Hello, My problem is that File.Exists works fine if my file is on my local drive but returns false if its on any other drive. I think that the issue is probably file permissions and so I have...
0
by: Lokkju | last post by:
I am pretty much lost here - I am trying to create a managed c++ wrapper for this dll, so that I can use it from c#/vb.net, however, it does not conform to any standard style of coding I have seen....
13
by: George | last post by:
Hi, I am re-writing part of my application using C#. This application starts another process which execute a "legacy" program. This legacy program writes to a log file and before it ends, it...
16
by: Eran.Yasso | last post by:
Hi, I have a mdb file shared in the LAN. I want to write app that verifies if it's open. If the file is not open, then my app can open the file. if the file is used, then the app won't open it....
5
by: =?Utf-8?B?QWRyaWFuTW9ycmlz?= | last post by:
Hello! I'm trying to copy a file from another computer on the network that I do not have permission with my current logon details to access. If I open the folder using the Windows file manager...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.