为什么我的java类没有使用smb连接到远程驱动器(使用正确的用户名和密码时)?

时间:2017-05-10 11:04:09

标签: java eclipse networking smb

为什么我的java类没有使用smb连接到远程驱动器?

    String user = "user1";
    String pass ="pass234";

    String sharedFolder="c$\\WebDocs2\\AutoFrameworkResults\\";
    String path= "smb:" +"\\" + "\\192.xx.1.xx\\" + sharedFolder + "Example.txt";
    NtlmPasswordAuthentication auth = new NtlmPasswordAuthentication("",user, pass);
    SmbFile smbFile = new SmbFile(path,auth);
    SmbFileOutputStream smbfos = new SmbFileOutputStream(smbFile);
    smbfos.write("testing....and writing to a file".getBytes());
    System.out.println("completed ...nice !");

我得到以下异常(但用户名和密码凭据是正确的)?`

Exception in thread "main" jcifs.smb.SmbAuthException: Logon failure: unknown user name or bad password.
    at jcifs.smb.SmbSession.sessionSetup(SmbSession.java:406)
    at jcifs.smb.SmbSession.send(SmbSession.java:218)
    at jcifs.smb.SmbTree.treeConnect(SmbTree.java:176)

0 个答案:

没有答案