【问题标题】:unable to connect to unc location using jcifs无法使用 jcifs 连接到 unc 位置
【发布时间】:2018-06-21 06:14:36
【问题描述】:

我有一些属于同一域的远程位置。当我从 Windows 访问远程位置时,它会在不要求凭据的情况下打开。但是如果我使用 java 代码 (jcifs) 访问该位置,那么它会给我这个异常

jcifs.smb.SmbAuthException:登录失败:未知用户名或错误 密码

Java 代码是

String path=convertToSmb(loc);
        NtlmPasswordAuthentication auth=new NtlmPasswordAuthentication(path, userName, passwd);
        SmbFile sFile=null;
        try {
            sFile=new SmbFile(path,auth);
            sFile.connect();
            boolean sFileExists = sFile.exists();
            logger.info("checkUNCLocation [END] with :: sfileExists :: "+sFileExists);
            return sFileExists;
        } catch (MalformedURLException e) {
            logger.error(e.getMessage(), e);
            return Boolean.FALSE;
        } catch (IOException e) {
            logger.error(e.getMessage(), e);
            return UNCNetworkConnectionWrapper.connectUNCNetwork(loc, userName, passwd);
        }finally{

            sFile=null;
            //jcifs.Config.setProperty("jcifs.smb.client.disablePlainTextPasswords", Boolean.TRUE.toString());
        }

我尝试使用 net use delete 删除所有连接,但 windows 仍然没有要求提供凭据

日志记录还显示正确的凭据。 请指导应该是什么原因。

【问题讨论】:

    标签: java unc jcifs


    【解决方案1】:

    你试过设置userNamepassword吗??

    Windows 如何通过尝试使用当前凭据连接服务器来做到这一点,如果您与您的用户连接并且您尝试连接到同一域中的其他计算机,则连接将成功,因为您的凭据有效在这个域中。

    尝试使用您自己的凭据连接到“此”服务器。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2014-09-14
      • 2013-07-30
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-11-17
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多