Android Studio中的CIFS/SMB网络协议格式化问题
我在android studio项目中安装了jcifs-1.3.19 jar 我想知道为什么我总是收到“W/System.err:jcifs.smb.SmbAuthException:Logon failure:未知用户名或错误密码”的异常 我已使用“ES文件浏览”成功访问了我公司的Windows网络驱动器。我有正确的凭据(登录和pswd)。该公司“IT”服务台表示,SMB路径格式如下: “静态最终字符串AUTH_PATH=“smb://”+用户名+:“+密码”@engstl1.us.crownlift.net/vol1/PIL_SYNECT_TEST_PLAN/Ready_for_Exectuion/”;” 这是行不通的。我做错什么了吗?此代码正在异步任务中执行Android Studio中的CIFS/SMB网络协议格式化问题,android,smb,Android,Smb,我在android studio项目中安装了jcifs-1.3.19 jar 我想知道为什么我总是收到“W/System.err:jcifs.smb.SmbAuthException:Logon failure:未知用户名或错误密码”的异常 我已使用“ES文件浏览”成功访问了我公司的Windows网络驱动器。我有正确的凭据(登录和pswd)。该公司“IT”服务台表示,SMB路径格式如下: “静态最终字符串AUTH_PATH=“smb://”+用户名+:“+密码”@engstl1.us.crown
static final String AUTH_PATH = "smb://" + USER_NAME + ":" + PASSWORD + "@engstl1.us.crownlift.net/vol1/PIL_SYNECT_TEST_PLAN/Ready_for_Exectuion/"; // From email
String Path = AUTH_PATH + "testfile.text"; // From email
static final String fileContent = "Here is something in this file";
static boolean successful;
@Override
protected void onPreExecute() {
Log.i(TAG, "in AsyncTask onPreExecute"); // debug msg
}
@Override
protected String doInBackground(Void... voids) {
try{
Log.i(TAG, "IN AsyncTask in try ---------------------------->:" ); // debug msg
String user = USER_NAME + ":" + PASSWORD;
System.out.println("User: " + user);
NtlmPasswordAuthentication auth = new NtlmPasswordAuthentication(user);
//String path = NETWORK_FOLDER + "testfile.txt";
String path = Path; // From email
System.out.println("Path: " + path);
Log.i(TAG, "IN doInBackground method in try after NtlmPasswordAuthentication ---------------------------->:" + auth); // debug msg
SmbFile sFile = new SmbFile(path, auth);
Log.i(TAG, "IN doInBackground method in try after sFile---------------------------->:" + sFile ); // debug msg
SmbFileOutputStream sfos = new SmbFileOutputStream(sFile,true);
Log.i(TAG, "IN doInBackground method in try after sfos---------------------------->:" + sfos ); // debug msg not getting here
sfos.write(fileContent.getBytes());
successful = true;
System.out.println("Successful" + successful);
} catch (Exception e) {
successful = false;
Log.i(TAG, "IN doInBackground method Exception---------------------------->:" ); // debug msg
e.printStackTrace();
Logcat:
05-30 13:58:32.180 22183-26454/com.example.t0028919.person_in_looptesttool
I/TomsMessage: IN doInBackground method Exception---------------------------
->:
05-30 13:58:32.180 22183-26454/com.example.t0028919.person_in_looptesttool
W/System.err: jcifs.smb.SmbAuthException: Logon failure: unknown user name
or bad password.
05-30 13:58:32.180 22183-26454/com.example.t0028919.person_in_looptesttool
W/System.err: at
jcifs.smb.SmbTransport.checkStatus(SmbTransport.java:546)
05-30 13:58:32.180 22183-26454/com.example.t0028919.person_in_looptesttool
W/System.err: at jcifs.smb.SmbTransport.send(SmbTransport.java:663)
05-30 13:58:32.180 22183-26454/com.example.t0028919.person_in_looptesttool
W/System.err: at jcifs.smb.SmbSession.sessionSetup(SmbSession.java:390)
05-30 13:58:32.180 22183-26454/com.example.t0028919.person_in_looptesttool
W/System.err: at jcifs.smb.SmbSession.send(SmbSession.java:218)
我不认为“ES File Explore”使用的是jcifs,因为它使用的是smb2,而jcifs只使用smb1。Smb1不安全几乎每个操作系统都禁用Smb1流量Hello Eliad,感谢您的回复。我注意到你在上一篇文章中提到“通过SMBJ进行Android smb2文件传输”。我做了更多的研究,看起来Windows服务器版本确实正在远离smb1。如果jcifs只支持smb1,那么您会建议改用smbj-0.6.0.jar库吗?它的工作原理是否与jcifs类似?再次感谢您,TomIt,如果您只需要连接而不使用加密(我不认为smbj支持或完全支持smb3),并且您可以使用开源,那么是的。但如果您需要加密和商业许可证,您可以通过Visuality Systems使用jNQ。