Root object of the System API, used for accessing the CompleteFTP server's internal state. Accessed via the global variable 'system'.
Members
(static) currentFolder
The current working directory for the current session. Can be read and assigned.
(static) passwordPolicy
Password policy applied to new passwords.
The object has the properties listed below:
Properties:
Name | Type | Description |
---|---|---|
allowChange |
Boolean | True if users are allowed to change their own password. |
minLength |
Number | Minimum number of characters required. |
mustHaveMixedCase |
Boolean | True if passwords must have at least one upper-case and at least one lower-case letter. |
mustHaveDigit |
Boolean | True if passwords must include at least one digit. |
mustHaveSpecialChar |
Boolean | True if passwords must include at least one of the following characters: !"#$%&'()*+,-./: |
(static) server
Represents the current server.
Properties:
Name | Type | Description |
---|---|---|
name |
String | Name of the server. |
ipAddresses |
Array.<String> | IP addresses available on the server. |
(static) site :SiteInfo
Represents the CompleteFTP site that is serving up this script.
Type:
(static) user
Represents the currently logged in user or the anonymous user, if a user isn't logged in.
The object has the properties listed below, as well as a method changePassword(newPassword)
,
which changes the password of the user to newPassword
.
Properties:
Name | Type | Description |
---|---|---|
userName |
String | User-name of the user (excluding any domain-name). |
fullUserName |
String | Full user-name of the user (including any domain-name). |
domainName |
String | Domain-name of the user. |
isAnonymous |
Boolean | True if no user is currently logged in. |
homeFolder |
String | Absolute path of the user's home-folder. |
apparentHomeFolder |
String | Path of the user's home-folder as it appears to the user. |
sharingEnabled |
Boolean | True is sharing is enabled for this user. |
tags |
Object | Encapsulates a set of name-value pairs whose lifetime is that of the session. Methods:
|
Methods
(static) checkLogin(extraCheckFunctionopt)
Checks if a user is logged in and throws an 'unauthorized access' exception if not. In HTTP, this will result in a 401 error being returned to the client. A function may optionally be passed in if additional checks are required. This function will trigger an exception if it returns a string or if it throws an exception.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
extraCheckFunction |
String |
<optional> |
Optional function that can implement checks in addition to the default login check. If this function returns a string or throws an exception then an error will be triggered with message returned or thrown. |
(static) executeCustomCommand(commandName, parametersopt) → {String}
Executes a custom command and returns the result. Custom commands are methods that have been implemented in .NET Custom Command Extensions and JSS Custom Command Scripts. There are some inbuilt commands, including administration commands and the file-sharing commands (ask support), but you can also add your own.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
commandName |
String | Name of the custom command (e.g. "useradd") |
|
parameters |
Array.<String> |
<optional> |
Arguments to be passed to the command. |
Returns:
Result of the command.
- Type
- String
(static) getConfig() → {Config}
[Admins only] Returns a Config object representing the current configuration of CompleteFTP server. This function may only be executed by members of the admins group or by scripts that are owned by members of the admin group.
Returns:
- Type
- Config
(static) getFile(path) → {File}
Returns a File object for the given path.
The File object may or may not represent an existing file or directory.
Parameters:
Name | Type | Description |
---|---|---|
path |
String | Path of file |
Returns:
- Type
- File
(static) getPublicKeyInfo() → {PublicKeyInfo}
Returns the type and fingerprint of key stored in the encodedKey argument, as well as the same key in OpenSSH format, which is the format CompleteFTP uses to store key internally.
Returns:
Key information or null if the key could not be parsed.
- Type
- PublicKeyInfo
(static) login(userName, password, usePublicFolderAsRootopt, persistentCookieopt)
Log in using the given user-name and password, or throws an exception indicating that the user could not be authenticated. Until this function is invoked the active user will be the 'anonymous' user. Logins are associated with session IDs, which are stored in a cookie named "__cftp_sessid". Cookies must therefore be enabled for logins to work. Users must be set up within CompleteFTP. If users are to be managed from within the web-app then CompleteFTP's database authentication should be used in combination with the server-side WebSQLDatabase feature (see openDatabaseSync). Use the user property to access information about the active user.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
userName |
String | User-name |
|
password |
String | Password |
|
usePublicFolderAsRoot |
Boolean |
<optional> |
If |
persistentCookie |
Boolean |
<optional> |
If |
(static) logout()
Log out the current user.
(static) openDatabaseSync(connectionString) → {DatabaseSync}
Opens a connection to the database with the given connection-string. The connectionString
must be
either the virtual file-system path of an SQLite or SQL Server Compact file, or a
prefixed database connection-string. The prefixes are shown below:
Connection-type | Prefix | File-extension | Database DLLs required? |
---|---|---|---|
SQLite | sqlite:* | .sqlite3 | no |
SQL Server Compact | sqlserverce:* | .sdf | no |
SQL Server | sqlserver: | n/a | no |
ODBC | odbc: | n/a | no |
OLE DB | oledb: | n/a | yes** |
* - Prefixes are only required for SQLite and SQL Server Compact if the listed file-extension isn't being used.
** - For OLE DB connections the DLLs for the specific database being accessed must be placed in the same directory as the CompleteFTP server executables.
Parameters:
Name | Type | Description |
---|---|---|
connectionString |
String | Connection-string. |
Returns:
- Type
- DatabaseSync
(static) sudo(action)
[Admins only] sudo = Super-User DO. Like its UNIX counterpart, this function executes the given action in the admin user context. Windows resources will be accessed in the context of the user that's running the CompleteFTP service, which by default is SYSTEM. Care should be taken when using this function as the admin user has much greater permissions than non-admin users, so there is a higher potential for misbehaviour. This function may only be executed by members of the admins group or by scripts that are owned by members of the admin group.
Parameters:
Name | Type | Description |
---|---|---|
action |
function | Function containing the actions to be run in the admin user context. |