android - Android Studio 格式化问题中的 CIFS/SMB 网络协议
问题描述
我在 android studio 项目中安装了 jcifs-1.3.19 jar。
我想知道为什么我不断收到“W/System.err:jcifs.smb.SmbAuthException:登录失败:未知用户名或密码错误”的异常。
我已经使用“ES File Explore”成功访问了我公司的 Windows 网络驱动器。我有正确的凭据(登录名和密码)。公司“IT”服务台表示,SMB 路径格式如下:
"静态最终字符串 AUTH_PATH = "smb://" + USER_NAME + ":" + PASSWORD "@engstl1.us.crownlift.net/vol1/PIL_SYNECT_TEST_PLAN/Ready_for_Exectuion/";"
这不起作用。有什么我做错了吗?此代码在 AsyncTask 中执行。
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)
解决方案
推荐阅读
- python - 从 mariadb 填充组合框可编辑的 human_name 和行编辑电话和电子邮件
- reactjs - 我正在尝试将静态反应应用程序部署到heroku,但出现“cross-env:未找到”之类的错误
- matlab - Matlab绘图,从图例中删除线
- flutter - 如何修复 VSCODE 模拟器?
- javascript - date-fns 如何以 23:59:59 的 00:00:00 格式获取一天的结束
- android - 处理来自外部条码扫描器的数据
- python - 我需要从石墨烯查询发送响应。问题是响应应该包含仅基于用户角色的特定字段
- java - 在 Android 中使用其列表值对 HashMap 进行排序(Map
>) - css - Firefox 和 chrome 中不同尺寸的跨浏览器显示问题(仅限移动设备)
- flutter - 运行“颤振医生--android-licenses”时出错