Edu Posted September 21, 2016 Report Share Posted September 21, 2016 Prezados, Bom dia! Eu tenho uma rotina de conexão com servidor FTP que funcionava bem com a Locaweb, porém mudamos para Hostgator e parou de funcionar. Ao tentar conectar retorna o erro: 530 - Login authentication failed. Obs.: No Filezilla e pelo cmd funciona normal. Alguém sabe me dizer a causa disso. ******************************************************************************** FUNCTION ConnectFTP() * Estabelece a conexao com o servidor FTP LOCAL aFiles, lExistDir IF !IsInternet() Msginfo("Você não está conectado à internet!", "Atenção") RETURN NIL ENDIF PARAM_CON() // obtem as variaveis de conexao cUrl := "ftp://" + cUser + ":" + cPassword + "@" + cServer oUrl := tUrl():New( cUrl + cDirectory ) oFTP := tIPClientFtp():New( oUrl, .T. ) oFTP:nConnTimeout := 20000 oFTP:bUsePasv := .T. // Comprobamos si el usuario contiene una @ para forzar el userid IF At( "@", cUser ) > 0 oFTP:oUrl:cServer := cServer oFTP:oUrl:cUserID := cUser oFTP:oUrl:cPassword := cPassword ENDIF IF oFTP:Open( cUrl ) * Obtem a lista de arquivos e pastas na raiz do FTP aFiles := oFtp:listFiles() * verifica se o diretorio principal existe lExistDir:= .f. FOR i:= 1 TO LEN(aFiles) IF aFiles[i,1] == "VALIDADE" lExistDir:= .t. ELSE lExistDir:= .f. ENDIF NEXT * Se nao existir, cria o diretorio IF !lExistDir oFtp:mkd( "VALIDADE" ) // cria a pasta dentro do ftp ENDIF oFtp:Cwd("VALIDADE") // acessa o diretorio Msginfo("Conexão com servidor FTP estabelecida com sucesso!", "Ok") lConnected:= .t. Grava_historico("Conexão com o Servidor FTP iniciada") ELSE cStr := "Não foi possível conectar com o servidor FTP" + " " + oURL:cServer IF oFTP:SocketCon == NIL cStr += Chr( 13 ) + Chr( 10 ) + "Conexão não inicializada" ELSEIF InetErrorCode( oFTP:SocketCon ) == 0 cStr += Chr( 13 ) + Chr( 10 ) + "Resposta do servidor:" + " "+ oFTP:cReply ELSE cStr += Chr( 13 ) + Chr( 10 ) + "Erro na conexão:" + " " +InetErrorDesc( oFTP:SocketControl ) ENDIF msgstop(cStr,"Erro") ENDIF RETURN NIL Quote Link to comment Share on other sites More sharing options...
kapiaba Posted September 21, 2016 Report Share Posted September 21, 2016 http://stackoverflow.com/questions/10695290/ftp-error-530-login-authentication-failed https://groups.google.com/forum/#!topic/harbour-users/vf-U0pJk2TY Quote Link to comment Share on other sites More sharing options...
Edu Posted September 21, 2016 Author Report Share Posted September 21, 2016 Kapiaba, Não consegui! Interessante que se eu colocar o nome do usuário = usuario@dominio.com.br, não consegue estabelecer conexão. Como se a url estivesse mal formada. Dá erro logo de cara. Mas se eu colocar só o nome do usuário, ele estabelece a conexão e retorna o erro de autenticação. Não sei mais o que fazer... Quote Link to comment Share on other sites More sharing options...
mkyx Posted September 21, 2016 Report Share Posted September 21, 2016 faltou a linha: oFTP:nDefaultPort := 21 ------------------------------------------------------------------------ // na sequencia: cUrl := "ftp://" + cUser + ":" + cPassword + "@" + cServer oUrl := tUrl():New( cUrl ) oFTP := tIPClientFtp():New( oUrl, file("desenv.sys") ) oFTP:nDefaultPort := 21 oFTP:nConnTimeout := 12000 oFTP:bUsePasv := .T. if At("@",cUrl)>0 oFTP:oUrl:cServer := cServer oFTP:oUrl:cUserID := cUser oFTP:oUrl:cPassword := cPassword endif Quote Link to comment Share on other sites More sharing options...
Edu Posted September 22, 2016 Author Report Share Posted September 22, 2016 Caro mkyx, Não resolveu. Quote Link to comment Share on other sites More sharing options...
ADutheil Posted September 26, 2016 Report Share Posted September 26, 2016 oUrl := tUrl():New( cUrl + cDirectory ) De onde vem este cDirectory? Eu tentaria algo assim: oUrl := tUrl():New( "ftp://" + cServer ) oFTP := tIPClientFtp():New( oUrl, .T. ) xBrowse( oFtp ) // para ver se o objeto foi criado certinho oFTP:nConnTimeout := 20000 oFTP:bUsePasv := .T. oFTP:oUrl:cServer := cServer oFTP:oUrl:cUserID := cUser oFTP:oUrl:cPassword := cPassword Algum motivo para nao usar o curl easy? Quote Link to comment Share on other sites More sharing options...
Edu Posted September 26, 2016 Author Report Share Posted September 26, 2016 Caro ADutheil, A variavel cDirectory está vazia neste momento. Já tentei deste modo mas não funcionou. Acho que esta classe não suporta o protocolo TLS. Desconheço a curl easy, mas consegui com outra classe chamada qFtpClient. Para quem estiver interessado. Segue anexo. qFTPClient.txt Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.