FTPSERVERCONFIG  
 

The FTPSERVERCONFIG structure provides the configuration information used to create an instance of an FTP server.

typedef struct _FTPSERVERCONFIG
{
    DWORD   dwSize;
    UINT    nMaxClients;
    UINT    nMaxClientsPerAddress;
    UINT    nMaxGuests;
    UINT    nLogFormat;
    UINT    nLogLevel;
    UINT    nMinPort;
    UINT    nMaxPort;
    UINT    nAuthFail;
    UINT    nAuthTime;
    UINT    nIdleTime;
    UINT    nExecTime;
    LPCTSTR lpszIdentity;
    LPCTSTR lpszHostUuid;
    LPCTSTR lpszHostName;
    LPCTSTR lpszRootPath;
    LPCTSTR lpszTempPath;
    LPCTSTR lpszLogFile;
} FTPSERVERCONFIG, *LPFTPSERVERCONFIG;

Members

dwSize
An unsigned integer value that specifies the size of the structure.
nMaxClients
An integer value that specifies the maximum number of active client connections that will be accepted by the server. If the maximum number of clients is reached, any further connections are rejected by the server until one or more clients close their connection to the server or are disconnected. A value of zero specifies the default configuration value of 100 connections should be used.
nMaxClientsPerAddress
An integer value that specifies the maximum number of active client connections per IP address that will be accepted by the server. If the maximum number of clients from the same IP address is reached, any further connections are rejected until one of the clients closes its connection to the server. A value of zero specifies the default configuration value of 4 connections per address should be used.
nMaxGuests
An integer value that specifies the maximum number of anonymous client connections. If the server does not permit anonymous connections, this value is ignored. It is recommended that this value always be less than the value of the nMaxClients member. A value of zero specifies that the default configuration limit of 20 anonymous connections should be used.
nLogFormat
An integer value that specifies the format used when creating or updating the server log file. The following formats are supported:
Value Description
FTP_LOGFILE_NONE This value specifies that the server should not create or update a log file.
FTP_LOGFILE_COMMON This value specifies that the log file should use the common log format that records a subset of information in a fixed format. This log format usually only provides information about file transfers.
FTP_LOGFILE_EXTENDED This value specifies that the log file should use the standard W3C extended log file format. This is an extensible format that can provide additional information about the client session.
nLogLevel
An integer value that specifies the level of detail that should generated in the log file. The minimum value is 1 and the maximum value is 10. If the nLogFormat member specifies a valid log file format and this value is zero, a default level of detail will be selected based on the format. The common log file format generally contains less information by default, only logging the data transfers between the client and server. The W3C extended log file format defaults to a higher level of detail that includes additional information about the client session. The higher the level of detail, the larger the log file will be.
nMinPort
An integer value that specifies the minimum range of port numbers that will be used with passive data connections. A value of zero specifies that the default value of 30000 should be used. The minimum value of this member is 5000 and the maximum value is 65535. If the value is non-zero, it must be less than the value of the nMaxPort structure member.
nMaxPort
An integer value that specifies the maximum range of port numbers that will be used with passive data connections. A value of zero specifies the default value of 65535 should be used. The minimum value of this member is 5000 and the maximum value is 65535. If the value is non-zero, it must be greater than the value of the nMinPort structure member.
nAuthFail
An integer value that specifies the maximum number of user authentication attempts that are permitted until the server terminates the client connection. A value of zero specifies that the default configuration limit of 3 authentication attempts per login should be allowed. The maximum number of authentication attempts is 10.
nAuthTime
An integer value that specifies the maximum number of user authentication attempts that are permitted until the server terminates the client connection. A value of zero specifies the default value of 60 seconds. If the value is non-zero, the minimum value is 20 seconds and the maximum value is 300 seconds (5 minutes). This value is used to ensure that a client has successfully authenticated itself within a limited period of time. This prevents a potential denial-of-service attack against the server where clients establish connections and hold them open without authentication. In conjunction with the nAuthFail member, this also limits the ability of a client to attempt to probe the server for valid username and password combinations.
nIdleTime
An integer value that specifies the maximum number of seconds that a client session may be idle before the server closes the control connection to the client. A value of zero specifies the default value of 900 seconds (15 minutes). If the value is non-zero, the minimum value is 60 seconds and the maximum value is 7200 seconds (2 hours). This value is used to initialize the default idle timeout period for each client session. A client may request that the server change the idle timeout period for its session by sending the SITE IDLE command. The server determines if a client is idle based on the time the last command was issued and whether or not a file transfer is in progress.
nExecTime
An unsigned integer value that specifies the maximum number of seconds that an external program is permitted to run on the server. External programs are registered using the FtpRegisterProgram function, and are executed by the client sending the SITE EXEC command to the server. If this value is zero, the default timeout period of 5 seconds will be used. The minimum execution time is 1 second and the maximum time limit is 30 seconds.
lpszIdentity
A null-terminated string that identifies the server. It is used for informational purposes only and has no effect on the operation of the server. If this member is not initialized to a value, then a default identity will be used. The server identity is provided when a client establishes the initial connection and when the client sends the STAT or CSID commands. If this member is defined, it is recommended that you only use printable ASCII characters.
lpszHostUuid
A null-terminated string that specifies a Universally Unique Identifier (UUID) that is used to uniquely identify the server. This value can be used when storing information about the server, and should be generated using a utility such as uuidgen which is included with Visual Studio. This structure member may be initialized to an empty string, in which case a temporary UUID will be randomly generated.
lpszHostName
A null-terminated string that specifies the fully-qualified host name for the server. If this structure member is initialized with an empty string, the local host name assigned to the Windows system will be used. This value does not need to correspond to the actual host name associated with the server's IP address. This value is used for informational purposes only and has no effect on the operation of the server.
lpszRootPath
A null-terminated string that specifies the path to the root directory for the server. If this structure member is initialized with an empty string, the current working directory for the process will be used as the root directory. It is recommended that you provide a full path to an existing directory and do not specify the root of a local or network drive. If the path does not exist at the time the server is started, it will be automatically created.
lpszTempPath
A null-terminated string that specifies the path to the temporary directory for the server. If this structure member is initialized with an empty string, the current temporary directory for the process will be used. The temporary directory cannot be the same as the root directory, and it is strongly recommended that you do not specify the root of a local or network drive. If the path does not exist at the time the server is started, it will be automatically created.
lpszLogFile
A null-terminated string that specifies the name of the server log file to create, if a logging format has been specified. If logging is enabled and this member is an empty string, then a default log file name will be created. If the file name does not include a path, then the file is created in the server log directory. If the file name includes a path, the log file will be created using that specific name. If the server is in multi-user mode, then the default location for log files will be the Logs subdirectory in the server root directory. If the server is not in multi-user mode, the default location for log files will be the temporary directory for the server process.

Remarks

When an instance of this structure is passed to the FtpServerStart function, the dwSize member must be initialized to the size of the structure, otherwise the function will fail with an error indicating that the configuration is invalid.

The nMaxClients member limits the total number of client connections and the nMaxGuests member limits the total number of guest connections. The server will notify the client if either number of connections has been exceeded and will automatically close the connection. However, one difference is that a new client that exceeds the maximum number of connections will not generate any events; a client that exceeds the maximum number of guest connections will generate events. The reason for the difference is that the check for the number of active clients is made immediately after the client connects to the server, prior to session context being created for that client. The check for the number of anonymous clients is made later, after the client has sent the USER and PASS commands to the server. For more control over how the server accepts client connections, use the FtpServerThrottle function.

If the server is running on a system that is behind a firewall that restricts the range of port numbers for inbound connections, the nMinPort and nMaxPort members can be used to limit the ports which the server will use to listen for passive data connections from clients. By default, the server will use data port numbers that range from 30000 to 65535, which is typical for many firewall configurations. If you provide your own port range, the minimum number of ports available must be at least 1000. Specifying a port range that is too small will cause the FtpServerStart function to fail with an error indicating that the server configuration is invalid.

When specifying the root directory for the server configuration, it is important to consider that a client's access to files on the system will be limited to these directories and any subdirectories. If a root directory is not specified, then one will be created using the current working directory for the process. The root directory path may include environment variables surrounded by % symbols and these will be expanded.

If you have configured the server to permit clients to upload files, you must ensure that your application has permission to create files in the directory that you specify. A recommended location for the server root directory would be a subdirectory of the %ALLUSERSPROFILE% directory. Using the environment variable ensures that your server will work correctly on different versions of Windows. If the root directory does not exist at the time that the server is started, it will be created.

For servers that are publicly accessible, or where you want files to be a accessible across multiple server sessions, you should always populate the szHostUuid member with a valid UUID string, and the szDirectory member should specify an absolute path to an existing directory.

If the FTP_SERVER_MULTIUSER option is specified, the server will start in multi-user mode, with each user assigned to their own home directory based on their username. This option will cause the server to create a directory structure in the root directory that includes three subdirectories: Public, Users and Logs. The Public directory is the home directory for anonymous users, and they are isolated to that directory. The Users directory is where the user home directories are created. The Logs directory is where log files are created by default. If this option is not specified, then no subdirectories are created and all users will share the server root directory by default.

If the FTP_SERVER_LOCALUSER option is specified, the server will never attempt to authenticate the local Administrator or Guest accounts. This is done to prevent clients from attempting to probe for the administrator account password. However, the application can override this behavior by implementing a handler for the FTP_CLIENT_LOGIN event.

Requirements

Minimum Desktop Platform: Windows 7 Service Pack 1
Minimum Server Platform: Windows Server 2008 R2 Service Pack 1
Header File: cstools12.h
Unicode: Implemented as Unicode and ANSI versions

See Also