Solved

java file open with user credentials

Posted on 2008-10-07
2
1,663 Views
Last Modified: 2013-11-23
Is there a way to open a remote file using java by passing in user credentials.My java application is a windows service  and is not able to recoginze mapped drives , so I am using UNC paths, but now if my service login credentials are different than the remote machine where my file is, I cannot access it due to login failure.So i was wonderign if there is a way to open a remote file by checking the credentials of the  remote machine.
Thanks
0
Comment
Question by:res_this
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 9

Accepted Solution

by:
brunoguimaraes earned 500 total points
ID: 22662286
You can use jCifs: http://jcifs.samba.org/src/

The "official" version works only with NTLM authentication (windows 2000, NT, 98). But there is also a Kerberos version (windows 2003, xp, vista) that you can download in the same page.

There are several examples there too.

Here's an example using NTLM authentication (the only one I have worked with):


// to authenticate
InetAddress lInetAddress = InetAddress.getByName("ip address of the computer you're acessing"));
UniAddress lUniAddress = new UniAddress(lInetAddress);
NtlmPasswordAuthentication lNtlmPasswordAuthentication = new NtlmPasswordAuthentication("DOMAIN", "USERNAME", "PASSWORD");
SmbSession.logon(lUniAddress, lNtlmPasswordAuthentication);
 
// to open a file
SmbFile lSmbFile = new SmbFile("smb://path_to_file", lNtlmPasswordAuthentication);

Open in new window

0
 

Author Closing Comment

by:res_this
ID: 31503952
Thanks, that was a great answer
0

Featured Post

[Live Webinar] The Cloud Skills Gap

As Cloud technologies come of age, business leaders grapple with the impact it has on their team's skills and the gap associated with the use of a cloud platform.

Join experts from 451 Research and Concerto Cloud Services on July 27th where we will examine fact and fiction.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Java contains several comparison operators (e.g., <, <=, >, >=, ==, !=) that allow you to compare primitive values. However, these operators cannot be used to compare the contents of objects. Interface Comparable is used to allow objects of a cl…
A solution for Fortify Path Manipulation.
Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:
This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.

617 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question