FTP Proxy Methods

Question:

I need to connect to an ftp server and have to use the following command: ftp://username:password@hosname

That means I’m not able to use the standard connection (first connect to host, then enter username and then password).  Is this possible using the Chilkat FTP2 component?

Answer:

Yes.  There are a number of different FTP proxy methods used by different types of proxy servers.  Chilkat supports 6 different methods via the ProxyMethod property:

ProxyMethod = 1 (SITE site)

USER ProxyUsername
PASS ProxyPassword
SITE Hostname
USER Username
PASS Password

ProxyMethod = 2 (USER user@site)

USER Username@Hostname:Port
PASS Password

ProxyMethod = 3 (USER with login)

USER ProxyUsername
PASS ProxyPassword
USER Username@Hostname:Port
PASS Password

ProxyMethod = 4 (USER/PASS/ACCT)

USER Username@Hostname:Port ProxyUsername
PASS Password
ACCT ProxyPassword

ProxyMethod = 5 (OPEN site)

USER ProxyUsername
PASS ProxyPassword
OPEN Hostname
USER Username
PASS Password

ProxyMethod = 6 (firewallId@site)

USER ProxyUsername@Hostname
USER Username
PASS Password

The FTP2 component has these relevant properties:

Username
Password
ProxyUsername
ProxyPassword
ProxyHostname
ProxyPort
Port
ProxyMethod

Connecting via a proxy is as simple as setting the properties to appropriate values.  I’m sure you may not know exactly which ProxyMethod you need.  To help, there is a DetermineProxy method that can be called to automate the testnig of each proxy method.  Set the properties (ProxyUsername, ProxyHostname, etc.) to appropriate values and then call DetermineProxyMethod and let the component try to discover the proxy method that works.  It will return 0 if none were found, a value from 1 to 6 to indicate which proxy method was successful, or -1 for error.

Tags :