Reading a file in the network

Hi,

I need to access a file in the same LAN and read its contents. The machine name is something like Workstation22 and the file is located in D:\Parameters\SessionParameters.

Can I access the file, if the file is not shared? I am completely new to Java Networking. I googled and got an idea about the URL object. But can I use that in this case? I tried that and got a "Connection Refused" error.

It would be great if anybody can help me.

Thanks in advance,

Regards,

Swapna

[517 byte] By [Swapna_Ann_Jamesa] at [2007-11-27 4:59:40]
# 1

Generally this is not possible, in order for the file to accessible on the network from a machine it must be accessible through a UNC path (\\servername\sharename\file). If windows doesn't see that the file is shared, it will actively deny the request.

With all of that being said, you may want to try a unc path of \\servername\D$. this will connect to the default share of the D drive. Depending on whether or not your network admin has allowed these shares to stay unprotected will determine if you can connect.

joshholla at 2007-7-12 10:16:01 > top of Java-index,Core,Core APIs...
# 2
Thank you for the reply. I was waiting for a response from somebody. I have tried to access the machine's D drive using D$ and I am getting an access denied message. Is there any way I can supply the machine's credentials in the program to access the D: without sharing it?
Swapna_Ann_Jamesa at 2007-7-12 10:16:01 > top of Java-index,Core,Core APIs...
# 3
try thisopen run window then type the following\\machine name\d$it will as the user name and password give the authorized username
NelsonJosepha at 2007-7-12 10:16:01 > top of Java-index,Core,Core APIs...
# 4
But I need to supply the credentials thru the Java code. Not directly.
Swapna_Ann_Jamesa at 2007-7-12 10:16:01 > top of Java-index,Core,Core APIs...
# 5

If you are going from windows to windows you can try using runtime.exec

to execute

net use \\server\D$ /u:domain\user password

before you try to access the file.

I have never tried this otherwise i don't know how you will login to gain access to that share, I believe windows uses Kerberos Auth so you may want to check

http://www.microsoft.com/downloads/details.aspx?familyid=144f7b82-65cf-4105-b60c-44515299797d&displaylang=en

joshholla at 2007-7-12 10:16:01 > top of Java-index,Core,Core APIs...
# 6
Maybe this helps: http://jcifs.samba.org/ http://jcifs.samba.org/src/docs/api/jcifs/smb/SmbFile.html
Fokko_Stalmana at 2007-7-12 10:16:01 > top of Java-index,Core,Core APIs...
# 7
Fokko, Thanks for the link,s In all of my dealings with samba (I use a ldap domain controller for my network at home) i never realized they had a java client library.
joshholla at 2007-7-12 10:16:01 > top of Java-index,Core,Core APIs...
# 8

Hi Sapna,

Did you get your thing working with SmbFile? I am trying to do similar kind of stuff, reading files from a samba shared network, but end up getting an exception:

jcifs.smb.SmbException: All pipe instances are busy.

Cant understand where the problem is, and how to get over it? Any suggestions?

-Sam

sam504ua at 2007-7-12 10:16:01 > top of Java-index,Core,Core APIs...