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