Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

java file open with user credentials

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

Interactive Way of Training for the AWS CSA Exam

An interactive way of learning that will help you visualize core concepts so that you can be more effective when taking your AWS certification exam.  Built for students by a student to help them understand the concepts that they are being taught.

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…
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
The viewer will learn how to implement Singleton Design Pattern in Java.
This tutorial explains how to use the VisualVM tool for the Java platform application. This video goes into detail on the Threads, Sampler, and Profiler tabs.
Suggested Courses

722 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