我在android studio项目中安装了jcifs-1.3.19 jar。
我想知道为什么我一直得到" W / System.err的异常:jcifs.smb.SmbAuthException:登录失败:未知的用户名或密码错误。"
我使用" ES File Explore"成功访问了我的公司Windows网络驱动器。我有正确的凭据(login& pswd)。公司" 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)