1

Possible Duplicate:
Why does GetErrorMessage return “wrong password”, when the user name is wrong?

Since GetErrorMessage gave the same string for invalid password and username, I decided to use GetLastError(), as it has a separate error for each.

However with the incorrect username it still gives me the code 12014? (password error) but there IS a separate error code: ERROR_INTERNET_INCORRECT_USER_NAME - 12013

Shouldn't this work or is this intended too?

Thanks.

try
{
   pConnect = sess->GetFtpConnection(host, wronguserName, password, port, FALSE );
   err= GetLastError(); <---RETURNS INVALID PASSWORD with the wrong username??
}

catch (CInternetException* pEx) //incorrect user name displays incorrect password?
{
      TCHAR sz[1024];
      pEx->GetErrorMessage(sz, 1024);
      printf("ERROR!  %s\n", sz);
      pEx->Delete();
}
Community
  • 1
  • 1
T.T.T.
  • 33,367
  • 47
  • 130
  • 168

2 Answers2

4

The function can only tell you what the FTP server returns. The FTP server, being securely coded, says it's the wrong password. There's nothing the function can do to give you a different result from what the FTP server is telling it. :-P

For FTP servers that do distinguish between invalid usernames and invalid passwords (naughty, naughty), I'm sure the function will also just return you what the server returns, which in that case could be error 12013.

C. K. Young
  • 219,335
  • 46
  • 382
  • 435
3

The FTP server replies the same "invalid" message no matter if you get your account nor password wrong. This is to prevent phishing out valid usernames.

Kornel Kisielewicz
  • 55,802
  • 15
  • 111
  • 149