When you edit the LDAP server and change the port number, does the ' Test' button give you ' Successful' or an error (like ' Server unreachable' )?
Are you able to telnet to the AD server on port 340? (execute telnet <ipaddress> 340). With the LDAP telnet you won' t get any response back but the connection will open. To see a failed telnet, you can telnet to 341 for example then it should d/c immediately.
I' ve tried the test here and can confirm that the ' failed' error you' re receiving happens both when you try to connect to a correctly configured server (but enter the wrong credentials) or when you can' t connect to the LDAP server correctly (incorrect port, ip, no connectivity etc). It looks to be a catch all error.
Have you tried creating a new LDAP server with the new port number?