سؤال

JCIFS appears to have two modes for connecting to remote drives, the first being to create a connection that uses

SMBFile(path, new NtlmPasswordAuthentication(domain, username, password));

The second would use guest credentials

SMBFile(path);

I have a situation where a Java batch process attempts to connect to a remote location, I won't know the credentials in advance but the profile that is running the application has permission to access the remote SMB location. Is there a way to use the current running users credentials, without necessary prompting them for it?

هل كانت مفيدة؟

المحلول

Probably not the answer you're looking for, but JCIFS is a completely java-only implementation of the CIFS protocol. It has absolutely no way of inheriting credentials from the operating system.

If you're on the windows platform, though, you can use UNC file names to access the data e.g.

FileInputStream s = new FileInputStream("\\\\server\\share\\file.txt");

And as long as the credentials are available to the running Windows session, you should be using the user's own credentials.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top