I am having an issue connecting to a samba drive from a Java app using JCIFS. The trouble seems to be the url that JCiFS wants to connect. I can't enter servername/folder/folder because I do not have access to log into the server to get tot the folder. What I have is access via Samba to a folder on the server. I can map it via windows \\celery\\rim\\dev but can't use that in the url to pass to JCIFS.
The url below does not make it to the dev directory . I can get in if I just do smb://celery/rim/ but that is not the correct directory and I need to move down to the dev directory.
String url = "smb://celery/rim/dev/";
NtlmPasswordAuthentication auth = new NtlmPasswordAuthentication("domain", "user", "password");
try {
SmbFile dir = new SmbFile(url, auth);
String[] content = dir.list();
for(String file : content){
System.out.println(file);
}
@Eliad Cohen - I am sure that was the issue. I solved this by moving to JCIFS-ng. I just wish they had better documentation.
CIFSContext baseCxt = new BaseContext(new PropertyConfiguration(System.getProperties()));
NtlmPasswordAuthentication creds = new NtlmPasswordAuthentication(baseCxt, "am", nasProperties.getUsername(),nasProperties.getPassword());
CIFSContext ct = baseCxt.withCredentials(creds);
SmbFile dir = new SmbFile(url, ct);
SmbFileOutputStream sfos = new SmbFileOutputStream(dir);
sfos.write(csv.getBytes());
sfos.close();
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.