Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

java file open with user credentials

Posted on 2008-10-07
2
Medium Priority
?
1,685 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 2000 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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

By the end of 1980s, object oriented programming using languages like C++, Simula69 and ObjectPascal gained momentum. It looked like programmers finally found the perfect language. C++ successfully combined the object oriented principles of Simula w…
Introduction This article is the second of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers the basic installation and configuration of the test automation tools used by…
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…
The viewer will learn how to implement Singleton Design Pattern in Java.
Suggested Courses

886 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