3

以下は私のコードです

SmbFile catalExp = new SmbFile("smb://<Shared machine name>/Project share/Home/4.  Folders/planning - Design & Exec/sample.txt",
                    new NtlmPasswordAuthentication(LoadProp.getShrdDomain(),"user","paswd"));

これで私はエラーが発生しています

jcifs.smb.SmbException: The network name cannot be found
    at jcifs.smb.SmbTransport.send(SmbTransport.java:753)
    at jcifs.smb.SmbSession.sessionSetup(SmbSession.java:140)
    at jcifs.smb.SmbSession.send(SmbSession.java:103)
    at jcifs.smb.SmbTree.treeConnect(SmbTree.java:132)
    at jcifs.smb.SmbFile.connect(SmbFile.java:674)
    at jcifs.smb.SmbFile.connect0(SmbFile.java:644)
    at jcifs.smb.SmbFile.open0(SmbFile.java:700)
    at jcifs.smb.SmbFile.createNewFile(SmbFile.java:2027)

これはその特定の共有フォルダに対するユーザー権限と関係がありますか、それとも何か間違ったことをしていますか? アドバイスをお願いします

4

4 に答える 4

2

I ran into this error message, and it turned out the problem was that my network path was incorrect. You'll want to ensure that the NtlmPasswordAuthentication object is configured correctly, that your network path is correct, and that you've set the jcifs.netbios.wins property correctly, as indicated in the first example on this page.

For example, to load a remote properties file:

final NtlmPasswordAuthentication AUTH = new NtlmPasswordAuthentication("domainname", "username", "password");

Config.setProperty("jcifs.netbios.wins", "10.10.1.1");

Properties props = new Properties();
InputStream in = new SmbFileInputStream(new SmbFile("smb://10.10.1.1:445/rootfolder/path/filename.properties", AUTH));
props.load(in);

(You'll need to add try/catch and input stream closing)

A good way to ensure that all of your parameters are correct is to test logging into and locating the file using a smb/cifs client. For example smbclient on linux/unix:

smbclient -Uusername -p 139 //10.10.1.1/rootfolder

The domain is displayed at the top when you login with smbclient:

Domain=[DOMAINNAME]

..and you can navigate to your file to make sure you've got the path correct.

于 2013-05-26T05:07:12.770 に答える
0

このエラーも発生しますが、1つのデバイスでのみ、Android4.04で動作するコードは

 String strprog = "STRING CREATED| "; //debug log string
    try {
        strprog += "NTLM| ";
        NtlmPasswordAuthentication auth =  new NtlmPasswordAuthentication("username:password");
        strprog += "SMB| ";
        SmbFile file = new SmbFile("smb://<pcname>/foldername/filename.txt",auth);

        strprog += "EXIST| ";
        String there = String.valueOf(file.exists());

        strprog += "View| ";
        TextView pp;
        pp = (TextView) findViewById(R.id.tv);
        pp.setText(there);



    } catch (Exception e) {
        // TODO Auto-generated catch block
        strprog += "ERROR! ";
        TextView ll;
        ll = (TextView) findViewById(R.id.tv);


        ll.setText(strprog + e.getStackTrace().toString() + "    " +  e.getMessage() + "   " + e.getLocalizedMessage() );
    }

私が見る唯一の違いは、あなたが私のNtlmPasswordAuthものと比較してどこにいるのかということです。しかし、何らかの理由で述べたようにparam、smb:// hostを深く掘り下げると、Andriod 2.0でnull入力がスローされますが、これがお役に立てば幸いです。

于 2012-09-01T09:38:14.107 に答える
0

私はこの問題を抱えていて、Windows共有ドライブにマップされた共有名がわからなかったことが判明しました...そのため、Mac OSを使用して、次のように実行しました:

smbutil view smb://MYUSERNAME@HOSTNAME

パスワードの入力を求めるプロンプトが表示された後、共有名のリストが表示されました (Windows を使用してこれを見たときにはわかりませんでした)。共有名を見つけたら、JCIFS に接続するときにそれを使用するのと同じくらい簡単でした。

new SmbFile("smb://HOSTNAME/SHARENAME/path/I/was/trying/to/access", auth);

于 2015-01-23T15:17:37.347 に答える