У меня установлен jcifs-1.3.19 jar в проекте android studio.
Мне было интересно, почему я продолжаю получать исключение для "W / System.err: jcifs.smb.SmbAuthException: Ошибка входа в систему: неизвестное имя пользователя или неверный пароль. "
Я успешно получил доступ к сетевым дискам Windows моей компании с помощью" ES File Explore ".У меня есть правильные учетные данные (логин и pswd).Служба поддержки ИТ "IT" сообщила, что формат пути SMB таков:
"static final String 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)