views:

426

answers:

3

Hi All,

How can I read a text file resides in a remote machine? There is no share exists in that machine and I am not allowed to create any share or file in the remote machine. Also I am not allowed to run any client program in the remote machine. My program is a ASP.net in C# residing in a IIS webserver. For linux machine we used ssh connections and file reads are easy. Is there something by default available in windows similiar to it ?

Thanks, Sreejith

A: 

You could try accessing the Admin share of the machine. Windows by default created a share for all disks (named C$, D$ etc). But in that case the application you write should be running with the credentials of a user with rights to that share ((local) administrators have sufficient rights to do that).

If that doesn't work you need to create a share or install software to get files from that machine (like FTP). This is all because of security, it's a good thing you are not able to just read a file from any machine...

Gertjan
Thank you. I am writing a routine to first access default share, if it fails, try to create a share using wmi and read. Will let you know if it succeeds
+1  A: 

The first question to ask is if there's a good business reason to read that file. If yes, the IT people will have to allow you a reasonable solution to the problem.

I have frequently used SFTP (secure FTP) for this kind of problem. Unfortunately SFTP is not part of Windows, but there are free and low-cost SFTP servers available. Here's a list from Wikipedia

Explain to IT why you need access to that file and discuss options including SFTP. If you have a valid business reason for this and they will "not let you because of policy", it's the job of your project manager or boss to clear out that roadblock. Ask them to help.

Finally, consider whether it's practical for the file on the remote machine to be pushed to you instead of you pulling it. If you can setup a file share on your PC, ask them to setup a job on the remote server that copies the file to your file share every time it is changed.

Eric J.
The problem is that he does not want to install software. If he can alter the machine he wants to access it might be easier to create a file share. Also the pushing is a good idea, but has the same problem: work has to be done on the machine he wants to read from and unfortunately that is a no-go area.
Gertjan
I think Eric J. is trying to point out this is a policy/business problem - no a technial one.
premium_mesg_dev
That's right :-) If you need access to this file for a legitimate business purpose, the options are A) They give you access to the machine where the file is located in some form, or B) They push the file to someplace you are allowed to get it.
Eric J.
A: 

I have done this many time with the Remote File port 34 http://en.wikipedia.org/wiki/List_of_TCP_and_UDP_port_numbers

premium_mesg_dev
Port 34 is indeed the Remote file port, but that is used to access shares (sharing in windows is using that port). Since there are no shares and he is not able to create shares this is not a working solution. Since he is working with asp.net it is easier to just use the fileshare instead of communicating on a lower level like a port if there was a share anyway.
Gertjan