【发布时间】:2019-07-15 18:19:45
【问题描述】:
我正在使用 JCIFS 在 Windows 远程共享目录上创建一个目录。它不会失败验证,并继续调用 mkdir() 方法。但是,文件夹是在 linux 文件系统上创建的,位于 tomcat 安装目录的根目录,而不是在 Windows 共享目录中。没有任何异常。
我使用的是 JCIFS SMB 1.3.19 版。 Java 应用程序是一个 servlet,使用 Tomcat 在 linux 机器上运行。在进行 SMB 调用时,如代码块所示,应用程序会创建请求的目录,但它是在 Tomcat 安装目录的根目录下创建的。我在调用 mkdir() 方法之前使用了 NtlmPasswordAuthentication 。
public void create() {
try {
String smbUrl = String.format("smb://WIN-2016-AD-DNS/profiles/" + userName);
LOGGER.info("smbUrl = " + smbUrl);
NtlmPasswordAuthentication auth = new NtlmPasswordAuthentication(domain, "jdoe", "password");
SmbFile dir = new SmbFile(smbUrl, auth);
if (dir.isDirectory()) {
LOGGER.info("Directory already exists");
} else {
try {
dir.mkdir();
LOGGER.info("Successfully created folder on share");
} catch (Exception e) {
logExceptionError("Failed to create Directory with SMB mkdir", e, 0);
}
}
} catch (Exception e) {
logExceptionError("Failed to create Directory with SMB", e, 0);
}
}
...
【问题讨论】: