我尝试连接不同域中的服务器(源和目标都是WINDOWS)。连接失败。我通过wireshark嗅探流量并注意到我的程序始终与我记录的凭据连接。 我的代码:
UserAuthenticator auth = new StaticUserAuthenticator(serverConf.getDomain(), serverConf.getUsername(), serverConf.getPassword());
DefaultFileSystemConfigBuilder.getInstance().setUserAuthenticator(opts, auth);
FtpFileSystemConfigBuilder.getInstance().setUserDirIsRoot(opts, false);
if (serverConf.getFileSystem() == ServerConf.FileSystem.WINDOWS) {
filePath = "\\\\" + serverConf.getServerIP() + "\\" + serverConf.getFolder().replace(':', '$');
log.debug("filePath: "+filePath);
} else if (serverConf.getFileSystem()==ServerConf.FileSystem.FTP) {
filePath = "ftp://" + serverConf.getServerIP() + "/" + serverConf.getFolder().replace('\\', '/');
}
folder = VFS.getManager().resolveFile(filePath,opts);