Solved

java file open with user credentials

Posted on 2008-10-07
2
1,645 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
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

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

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

Suggested Solutions

Introduction This article is the first of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article explains our test automation goals. Then rationale is given for the tools we use to a…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
Viewers learn how to read error messages and identify possible mistakes that could cause hours of frustration. Coding is as much about debugging your code as it is about writing it. Define Error Message: Line Numbers: Type of Error: Break Down…
Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:

776 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