CFtpServer::GetProgramName Method  
 
INT GetProgramName(
  UINT nClientId,  
  LPTSTR lpszProgramName,  
  INT nMaxLength  
);
INT GetProgramName(
  UINT nClientId,  
  CString& strProgramName  
);

Return the name of the last program executed by the client.

Parameters

nClientId
An unsigned integer which uniquely identifies the client session.
lpszProgramName
A null-terminated string buffer that will contain the name of the last program executed by the client. This parameter cannot be NULL and should be at least 32 characters in size. An alternate version of this method accepts a CString object if it is available.
nMaxLength
An integer value that specifies the maximum number of characters that can be copied into the string buffer, including the terminating null character. This parameter must have a value greater than zero.

Return Value

If the method succeeds, the return value is the length of the command name. If the client ID does not specify a valid client session, the method will return zero. If the client has not executed any programs, this method will return zero.

Remarks

The GetProgramName method returns the name of the last program that was executed by the client using the SITE EXEC command. The name that is returned is the alias assigned to the program, not the full path to the executable file. The server application would typically use this method in an event handler when processing the FTP_CLIENT_EXECUTE event to determine which program has been executed on behalf of the client. The GetProgramExitCode method will return the program's exit code and the GetProgramOutput method can be used to obtain a copy of the output generated by the program.

Permission to use the SITE EXEC is not granted to authenticated users by default, and is limited to only those programs which are explicitly registered with the server. Exercise caution when allowing a client to execute a program on the server because this can expose the server to significant security risks. The programs that are registered for use with the SITE EXEC command should be thoroughly tested before being deployed on the server and should only be console programs that write to standard output.

Requirements

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

See Also