JCIFS - Transfer a file via SMB

1.3k views Asked by At

I'm trying to move some files from a stored directory to a remote server "BOB" using jcifs SMB. I need to use jcifs because the move comes via and Android app, I.E. I'm moving photos from the app to the remote server. In order to authenticate as a user, my company uses Active Directory. For some time, the Active Directory was the same server as the server where the photos would go, all is good. Unfortunately, they had to change the server where Active Directory is stored to "RAINY", but not where the photos are stored. So, I need to send these photos to "BOB" but use "RAINY" as the domain controller to login. Despite my best attempts, I'm getting an error "No Logon Servers Available to service the Logon request" It returns this error when it hits the "SMBFileOutputStream" line of code.

// Logon first.
UniAddress domainController = UniAddress.getByName("10.1.0.7");
SmbSession.logon(domainController, auth);

File moveMe = pics[k];
String cakeFolder = cupCakes[i].getName();
String transFolder = transfers[j].getName();
String destination = "smb://10.1.0.54/shared/Photos/Cupcakes/" +   cakeFolder + "/" + transFolder + "/" + moveMe.getName();

smbDest = new SmbFile(destination, auth);
SmbFileOutputStream out = new SmbFileOutputStream(smbDest);
FileInputStream fis = new FileInputStream(moveMe);
out.write(IOUtils.toByteArray(fis));
out.close();
1

There are 1 answers

0
squarewav On

Where are you getting "SmbSession.logon()" from?

If you're talking about doing a krb5 style login, JCIFS doesn't support Kerberos. You wouldn't be able to do that anyway since Android is not joined to the domain (or maybe Android can, I don't know).

Regardless, you must simply use plaintext credentials. More specifically, create an NtlmPasswordAuthentication object with your domain / username / password and pass it to SmbFile (or presumably SmbFileOutputStream would be better - see examples/Put.java).