Provides functionality to manipulate the contents of an endpoint by performing different actions. An action represents an operation such as copying a file or listing the contents of a directory. Supported endpoints are the local filesystem, network filesystems (using UNC) and FTP servers.
The component is based on a queue where actions are enqueued and then performed one at a time according to FIFO priority. The component starts by making a 'Get initial actions' call to retrieve the first set of actions to add to the queue. It then performs the first action in the queue after having made a 'Get extra information' call if the action requires extra information. After the action has been performed an 'Action performed' call is made to report whether the action was successful or not. The 'Action performed' call can optionally return new actions that are added to the queue. When the queue is empty the component makes a 'Finished' call and then terminates. To prevent the component from getting stuck in an infinite loop new actions can only be returned a finite number of times.
Most actions require a path to identify the entry on which to operate. The path is obtained by combining a base path specified on the endpoint with a path specified on the action. As an example, if the endpoint uses 'c:/foo' as base path and an action specifies '/bar' the combined path is 'c:/foo/bar'. It is not permitted to specify an action path that escapes the base path, i.e '/../bar' is not allowed.
The format for the base path depends on the type of endpoint. Filesystem endpoints support Windows style paths (for local paths such as 'c:/foo', but usually not for mapped network paths since they are user specific) and UNC ('\server\resource'). Long UNC, also known as UNCW, is not supported. The FTP endpoint uses unix style paths, i.e '/foo/'. Filesystem endpoints must specify a base path whereas ftp endpoints use '/' by default.
The format for the action is unix-style and it must adhere to the following requirements:
When specifying an action it is allowed to include additional columns that are not used to control the action. These columns are transformed into parameters known as 'Extra parameters' where each column corresponds to an extra parameter. The name, datatype and value of the parameters equals the name, datatype and value of the column. All NULL values are ignored, i.e. they do not generate an extra parameter with NULL as its value. These extra parameters are set when making the 'Get extra information' and 'Action performed' call for the corresponding action.
It is recommended that the extra parameter's value are kept reasonably small, i.e. large BLOBs should not be passed as extra parameters. Some names are reserved and hence not allowed to be used as extra parameters. The restricted names are the names of all parameters used by the component and the following additional names: 'Md5hash', 'Sha1hash', 'Timeout', 'Content', 'Zip', 'Unzip', 'Compress' and 'Decompress'.
The recommended priority when choosing endpoint is:
Protocol:
Authentication:
Password storage
Unlike SFTP the FTP/FTPS protocols are designed for humans and the communication is therefore not standardized. This leads to the support being dependent on the server implementation.
Servers known to work:
Servers with known issues:
It is recommended that before generating a keyfile reading up on what algorithms and key lengths are recommended online as this is continuously updated and support differs for different SFTP servers.
The key must be password-protected and you should use a strong password.
The following are examples of command prompt commands can be used to generate a key, depending on algorithm of choice:
ssh-keygen -t rsa -b 4096 -m PEM
ssh-keygen -t ed25519 -Z aes256-cbc
The private key is then stored on the web server, and referred to by the KeyFilePath column, and the public key is given to the host of the SFTP server.
If you have a keyfile for SFTP that is not protected by a password then you can convert it to a password-protected keyfile with the command
ssh-keygen -p -f mykeyfile -N mypassword
Create new Credentials of type Account. Put the SFTP username in the username field, and the password to decrypt the keyfile in the password field. Put the key file on the server.
Use the KeyFileCredentials and KeyFilePath columns. Read more.
Retrieve the initial actions to perform.
Possible value | Description |
---|---|
Init | The component requests initial actions to perform. |
Possible value | Description |
---|---|
Filesystem | The local filesystem or a network filesystem (using UNC-paths i.e '\\server/path/to/object') |
FTP | FTP (File Transfer Protocol) |
FTPS | FTP using explicit SSL. |
SFTP | SFTP (SSH File Transfer Protocol) |
This configuration is specific to SFTP and mandatory if KeyFilePath
is used. Otherwise, this value is ignored. The username from the KeyFileCredentials
must correspond the user on the SFTP server. The password in the KeyFileCredentials
is used to unlock the key file in KeyFilePath`.
Refer to the "Keyfile" section above for guidance on generating these necessary files.
This configuration is specific to SFTP. It specifies the path to the private keyfile located on the web server, which is used for authentication. It is imperative that this key is password-protected for security reasons.
When this column is used the password from KeyFileCredentials
is used to decrypt the keyfile. The username from the KeyFileCredentials
must correspond the user on the SFTP server.
Refer to the "Keyfile" section above for guidance on generating these necessary files.
Possible value | Description |
---|---|
CallProcedure | Make a call to the procedure without performing an action. |
ClearQueue | A special action that removes all actions from the queue. The removal is performed directly and no 'Action performed' call is made. It is considered an error if this action is not the first in a resultset. |
CopyDirectory | Copies a directory. The 'SourcePath' column specifies the directory to copy. The 'TargetPath' column specifies the target directory for the directory. The copied directory will have the same name as the source directory. As an example, if SourcePath is '/bar/' and TargetPath is '/foo' then the copied directory will be '/foo/bar/'. |
CopyFile | Copies a file. The 'SourcePath' column specifies the source file and the 'TargetPath' column specifies the target directory. The copied file will have the same name as the source file. |
CreateDirectory | Creates a directory. The 'TargetPath' column specifies the directory that should be created. |
DeleteDirectory | Deletes a directory. The 'SourcePath' column specifies the directory that should be deleted. It is considered an error if the directory is not empty and the action is not performed recursively. |
DeleteFile | Deletes a file. The 'SourcePath' column specifies the file that should be deleted. |
DirectoryExists | Checks whether a directory exists or not. The 'SourcePath' column specifies the path to check. This action will return false if a file with the specified path exists. |
FileExists | Checks whether a file exists or not. The 'SourcePath' column specifies the path to check. This action will return false if a directory with the specified path exists. |
Finish | When executed the component performs a 'Finished' call and then terminates. It is considered an error if this action is not the last in a resultset. |
HashFile | Calculates the hash of a file's content. The 'SourcePath' column specifies the file. |
List |
Lists all entries in a directory. The 'SourcePath'-column specifies the directory. NOTE! On IIS FTP servers, SourcePath must be '/'. To get the contents of a specific directory, do a recursive listing and filter on the ParentDirectory column of the #List temp table. |
MoveDirectory | Moves a directory. The 'SourcePath' column specifies the directory to move. The 'TargetPath' column specifies the target directory for the moved directory. The moved directory will have the same name as the source directory. As an example, if SourcePath is '/bar/' and TargetPath is '/foo' then the moved directory will be '/foo/bar/'. |
MoveFile | Moves a file. The 'SourcePath' column specifies the source file and the 'TargetPath' column specifies the target directory. The moved file will keep its name. |
ReadFile | Reads the content of a file. The 'SourcePath' column specifies the file. |
RenameDirectory | Renames a directory. The 'SourcePath' column specifies the directory to rename and the 'TargetPath' column specifies the new name of the directory excluding path. The renamed directory will remain in its original directory. |
RenameFile | Renames a file. The 'SourcePath' column specifies the source file and the 'TargetPath' column specifies the new name of the file excluding path. The file will remain in its original directory. |
WriteFile | Writes data to a file. The 'TargetPath' column specifies the file that the data should be written to. |
Possible value | Description |
---|---|
Md5 | The MD5 algorithm. |
Sha1 | The SHA1 algorithm. |
Call made to retrieve additional information if it is required to perform the action. The only action that requires extra information is 'WriteFile'.
Possible value | Description |
---|---|
1 | The component requires extra information to perform the action. |
Call made after an action has been performed.
Possible value | Description |
---|---|
0 | The action was performed successfully. |
-1 | An unknown error occurred, see @ErrorMessage for details. |
101 | Failed to open a data connection. |
11 | The source directory could not be found or access is denied. |
111 | Invalid SSL certificate. |
12 | The target directory could not be found or access is denied. |
13 | The target directory already exists. |
14 | The source directory is not empty. |
21 | The source file could not be found or access is denied. |
22 | The target file already exists. |
31 | The specified hostname could not be resolved. |
32 | The endpoint is not responding. |
41 | Authentication with end point failed. Verify that the supplied username / password are correct. |
5 | The specified path is invalid. |
6 | The base path does not exist. |
Possible value | Description |
---|---|
0 | The object does not exist. |
1 | The object exists. |
Possible value | Description |
---|---|
0 | The entry is a file. |
1 | The entry is a directory. |
Possible value | Description |
---|---|
0 | The entry is not marked as hidden. |
1 | The entry is marked as hidden. |
NULL | Unknown, no information provided by the endpoint. |
Possible value | Description |
---|---|
0 | The entry is not marked as readonly. |
1 | The entry is marked as readonly. |
NULL | Unknown, no information provided by the endpoint. |
Possible value | Description |
---|---|
Filesystem | The local filesystem or a network filesystem (using UNC-paths i.e '\\server/path/to/object') |
FTP | FTP (File Transfer Protocol) |
FTPS | FTP using explicit SSL. |
SFTP | SFTP (SSH File Transfer Protocol) |
This configuration is specific to SFTP and mandatory if KeyFilePath
is used. Otherwise, this value is ignored. The username from the KeyFileCredentials
must correspond the user on the SFTP server. The password in the KeyFileCredentials
is used to unlock the key file in KeyFilePath`.
Refer to the "Keyfile" section above for guidance on generating these necessary files.
This configuration is specific to SFTP. It specifies the path to the private keyfile located on the web server, which is used for authentication. It is imperative that this key is password-protected for security reasons.
When this column is used the password from KeyFileCredentials
is used to decrypt the keyfile. The username from the KeyFileCredentials
must correspond the user on the SFTP server.
Refer to the "Keyfile" section above for guidance on generating these necessary files.
Possible value | Description |
---|---|
CallProcedure | Make a call to the procedure without performing an action. |
ClearQueue | A special action that removes all actions from the queue. The removal is performed directly and no 'Action performed' call is made. It is considered an error if this action is not the first in a resultset. |
CopyDirectory | Copies a directory. The 'SourcePath' column specifies the directory to copy. The 'TargetPath' column specifies the target directory for the directory. The copied directory will have the same name as the source directory. As an example, if SourcePath is '/bar/' and TargetPath is '/foo' then the copied directory will be '/foo/bar/'. |
CopyFile | Copies a file. The 'SourcePath' column specifies the source file and the 'TargetPath' column specifies the target directory. The copied file will have the same name as the source file. |
CreateDirectory | Creates a directory. The 'TargetPath' column specifies the directory that should be created. |
DeleteDirectory | Deletes a directory. The 'SourcePath' column specifies the directory that should be deleted. It is considered an error if the directory is not empty and the action is not performed recursively. |
DeleteFile | Deletes a file. The 'SourcePath' column specifies the file that should be deleted. |
DirectoryExists | Checks whether a directory exists or not. The 'SourcePath' column specifies the path to check. This action will return false if a file with the specified path exists. |
FileExists | Checks whether a file exists or not. The 'SourcePath' column specifies the path to check. This action will return false if a directory with the specified path exists. |
Finish | When executed the component performs a 'Finished' call and then terminates. It is considered an error if this action is not the last in a resultset. |
HashFile | Calculates the hash of a file's content. The 'SourcePath' column specifies the file. |
List |
Lists all entries in a directory. The 'SourcePath'-column specifies the directory. NOTE! On IIS FTP servers, SourcePath must be '/'. To get the contents of a specific directory, do a recursive listing and filter on the ParentDirectory column of the #List temp table. |
MoveDirectory | Moves a directory. The 'SourcePath' column specifies the directory to move. The 'TargetPath' column specifies the target directory for the moved directory. The moved directory will have the same name as the source directory. As an example, if SourcePath is '/bar/' and TargetPath is '/foo' then the moved directory will be '/foo/bar/'. |
MoveFile | Moves a file. The 'SourcePath' column specifies the source file and the 'TargetPath' column specifies the target directory. The moved file will keep its name. |
ReadFile | Reads the content of a file. The 'SourcePath' column specifies the file. |
RenameDirectory | Renames a directory. The 'SourcePath' column specifies the directory to rename and the 'TargetPath' column specifies the new name of the directory excluding path. The renamed directory will remain in its original directory. |
RenameFile | Renames a file. The 'SourcePath' column specifies the source file and the 'TargetPath' column specifies the new name of the file excluding path. The file will remain in its original directory. |
WriteFile | Writes data to a file. The 'TargetPath' column specifies the file that the data should be written to. |
Possible value | Description |
---|---|
Md5 | The MD5 algorithm. |
Sha1 | The SHA1 algorithm. |
Call made when there are no more actions to perform or when performing the 'Finish' action.
Possible value | Description |
---|---|
Finished | The component has finished performing actions. |
Displays a user friendly error message to the user. This blocks any forwarding for the user.
Displays a user friendly confirmation message to the user with a delete button as the confirm button. If the user chooses OK the SQL call will be rerun with the parameter @ButtonAction set to 'Delete'.
Displays a user friendly confirmation message to the user with a question style. If the user chooses OK the SQL call will be rerun with the parameter @ButtonAction set to 'Confirm'.
Displays a user friendly confirmation message to the user with a warning style. If the user chooses OK the SQL call will be rerun with the parameter @ButtonAction set to 'Confirm'.
Displays a user friendly info message to the user. When the user clicks OK the user is forwarded.
Displays a user friendly success message to the user. When the user clicks OK the user is forwarded.
The dialog alias of a predefined dialog to show the user. Must be the first column in the result set table. Use multiple result set tables to combine with other forwarding.
Use the menu item "Admin > Dialogs" to register new dialogs or find aliases for existing ones.
Any column without special meaning in the result set with the first column ADMIN_Dialog will be used to make replacements of placeholders in the message and title text.
Additional information to show the developer when using ADMIN_Dialog.
Deprecated. Use ADMIN_CancelMenuItem instead.
Id of the menuitem to execute if the user clicks Cancel in an ADMIN_FORCE dialog (the default being none). This value overrides cancelmenuitemid specified in the query string.
Alias of the menu group to show after execution (instead of former menu item). This value overrides any destination specified by the query string.
Deprecated. Use ADMIN_ForwardMenuGroup instead.
Id of the menu group to show after execution (instead of former menu item). This value overrides any destination specified by the query string.
Deprecated. Use ADMIN_ForwardMenuItem instead.
Id of the menu item to execute after execution (instead of former menu item). This value overrides any destination specified by the query string.
Displays a user friendly error message to the user.
If this column is anything but NULL the popup will be closed and the parent will be reloaded. Only select this column if the menu item is opened in a popup. Avoid using this feature if the opener is a newEdit as that may interrupt the user's ongoing input.
Changes the text of the Cancel button when used with ADMIN_Force, ADMIN_ConfirmWarning, ADMIN_ConfirmQuestion, ADMIN_ConfirmDelete.
Changes the text of the OK button when used with ADMIN_ErrorMessage, ADMIN_ConfirmWarning, ADMIN_ConfirmQuestion, ADMIN_ConfirmDelete, ADMIN_InfoMessage, ADMIN_SuccessMessage, ADMIN_Message, ADMIN_Force, or ADMIN_Forward. ADMIN_Force,
Allows you to validate the SQL parameters before any other SQL is run in the component. This call is only made if the SQL is a stored procedure and Validate parameters is checked.
Use this call to restrict which entries a user is allowed to view and edit, and to log which entries a user views.
Access to a menu item is normally controlled through functions and roles alone but some entities need more fine grained control. For example, a user may have access to the View Member menu item for normal members but not for members with a protected identity.
The menu items a user visits are always logged (in ADMINLogMenuItem) but for sensitive data you may need to log exactly what entries are viewed. Do the logging in this call as the common ways of viewing data (grid and InfoSQL) are not allowed to modify the database.
If you bind a scalar function instead of a stored procedure to this call then its name must end with '_GrantAccess'.
CREATE TABLE Example.SftpFile
(
SftpFileId int IDENTITY CONSTRAINT PK_SftpFile PRIMARY KEY,
[ParentDirectory] nvarchar(max) NULL,
[Name] nvarchar(max) NULL,
[IsDirectory] bit NULL,
[IsHidden] bit NULL,
[IsReadOnly] bit NULL,
[DatetimeCreated] datetime NULL,
[DatetimeModified] datetime NULL,
[SizeInBytes] bigint NULL
);
GO
CREATE OR ALTER PROCEDURE Example.Sftp_ListFiles
@Action varchar(30) = NULL,
@SourcePath varchar(MAX) = NULL,
@ErrorCode int = NULL,
@ErrorMessage varchar(max) = NULL
AS
BEGIN
SET NOCOUNT, XACT_ABORT ON;
IF @Action = 'Init'
BEGIN
/* IMPORTANT: Never store passwords directly in your code
* or system settings for a production system!
* Instead, make use of Credentials to securely store passwords. */
DECLARE
@Server varchar(300) = '127.0.0.1',
@Username varchar(300) = 'bob',
@Password varchar(300) = 'secret';
SELECT
1 AS EndPointId,
'SFTP' AS EndPointType,
@Server AS [Address],
@Username AS [Username],
@Password AS [Password];
SELECT
1 AS EndPointIdSource,
'List' AS Action,
'/' AS SourcePath;
RETURN;
END;
IF @Action = 'List'
BEGIN
INSERT Example.SftpFile
(
ParentDirectory,
Name,
IsDirectory,
IsHidden,
IsReadOnly,
DatetimeCreated,
DatetimeModified,
SizeInBytes
)
SELECT
[ParentDirectory],
[Name],
[IsDirectory],
[IsHidden],
[IsReadOnly],
[DatetimeCreated],
[DatetimeModified],
[SizeInBytes]
FROM
#List;
RETURN;
END;
IF @ErrorCode <> 0
BEGIN
RAISERROR('%s', 16, 1, @ErrorMessage);
RETURN;
END;
IF @Action = 'Finished'
BEGIN
RETURN;
END;
END;