Navigation: Advanced Features > Server Lua API > User and Group |

c_AddUser(string strDomain,string strUsername,string strPassword,int nProtocolType,int bEnablePassword,int bEnableAccount,int nMaxDownloadSpeed,int nMaxUploadSpeed,int nMaxConnection,int nConnectTimeout,int nIdleTimeout,int nConnectPerIp,int nPassLength,int bShowHiddenFile,int bChangePass,int bSendMessage,int nRatioCredit, int nRatioDownload, int nRatioUpload, int nRatioCountMethod,int bEnableRatio,int nCurrentQuota,int nMaxQuota,int bEnableQuota, string strNoteName, string strNoteAddress,string strNoteZip,string strNotePhone,string strNoteFax,string strNoteEmail, string strNoteMemo, table tabUserDirectory, table tabUserIpmasks, table tabUserFilemasks, table tabUserUsergroups,int bEnableSchedule, table tabUserSchedules, int nLimitResetType, int bLimitEnableUpload, int nCurUploadSize,int nMaxUploadSize, int bLimitEnableDownload, int nCurDownloadSize, int nMaxDownloadSize,int bEnableExpire, string strExpireTime, int nMaxDownloadSpeedPerUser, int nMaxUploadSpeedPerUser,string strSSHPubKey, table tabSubFolderPerm, int bEnableSSHPubKey, int nSSHAuthMethod, int bEnableWeblink, int bEnableUplink, int bEnable2FA, string str2FACode, string strExtraInfo)

Parameters

[1]string the domain name

[2]string the user name

[3]string password with SHA256/MD5 encryption. If a salt string is defined under Domain > Settings > General Settings > Password & Security, also need to append that salt string after the password: SHA256(Password+SaltString)

[4]int enabled protocols mask, FTP=1, FTPES(explicit SSL)=2, FTPS(implicit SSL)=4, HTTP=8, HTTP(SSL)=16, SSH=32, if only FTP and HTTP are allowed, the mask number will be 1+8=9.

[5]int enable password, 1=yes, 0=no

[6]int enable account, 1=yes, 0=no

[7]int max download speed for one session

[8]int max upload speed for one session

[9]int max number of connections

[10]int ftp connection timeout value

[11]int ftp idle timeout value

[12]int max number of connections per Ip

[13]int max password length

[14]int show the hidden file?, 1=show,0=hide

[15]int user can change password?, 1=allow,0=deny

[16]int send chat message?, 1=allow,0=deny

[17]int credit ratio

[18]int download ratio

[19]int upload ratio

[20]int ratio count method, 0=count for files,1=count for bytes

[21]int enable ratio, 1=yes, 0=no

[22]int current quota size

[23]int max quota size

[24]int enable quota, 1=yes,0=no

[25]string note name

[26]string note address

[27]string note zipcode

[28]string note phone number

[29]string note fax number

[30]string note email

[31]string note memo

[32]table a table list of user directory, {user directory} is a table structure which is formated as: {m_strDir,m_strAlias,m_bIsHomeDir,m_bFileRead,m_bFileWrite,m_bFileAppend,m_bFileDelete,m_bDirectoryList,m_bDirectoryMake,m_bDirectoryDelete,m_bDirectoryRename,m_bFileRename,m_bZipFile,m_bUnzipFile}

[33]table a table list of user ipmask, {user ipmask} is a table structure which is formated as: {m_strIp,m_bRefuse}

[34]table a table list of user filemask, {user filemask} is a table structure which is formated as: {m_strMask,m_bRefuse}

[35]table a table list of user group, {user group} is a table structure which is formated as: {m_strGroupname}

[36]int enable access schedule, 1=yes,0=no

[37]table a table list of access scheduler, {access scheduler} is a table structure which is formated as: {m_nWeekday,m_strTimefrom, m_strTimeto}

[38]int transfer limit reset type, 0=reset never,1=reset hourly,2=reset daily,3=reset weekly,4=reset monthly

[39]int enable upload limit, 1=yes, 0=no

[40]int current upload size

[41]int max upload size

[42]int enable download limit, 1=yes, 0=no

[43]int current download size

[44]int max download size

[45]int enable account expire, 1=yes, 0=no

[46]string account expire time string, e.g. "2010-04-01 13:30:01"

[47]int max download speed for user

[48]int max upload speed for user

[49]string ssh public key path

[50]table subfolder access rules

[51]int enable ssh public key authentication, 1=yes,0=no

[52]int ssh authentication method, 1=Use both public key and password authentication,0=Only use public key authentication

[53]int enable web download link, 1=yes,0=no

[54]int enable web request (upload) link, 1=yes,0=no

[55]int enable two-factor authentication (TOTP) for Web Client, 1=yes,0=no

[56]string TOTP secret code

[57]string extra information for the user account

Return Values

nil

Remarks

Add or modify a user account.

c_UserExist(string strDomain, string strUsername)

Parameters

[1]string the domain name

[2]string the user name

Return Values

[1]bool return true if the specified user exists in the specified domain, otherwise return false

Remarks

Check whether the specified user exists.

c_GetUser(string strDomain,string strUsername)

Parameters

[1]string the domain name

[2]string the user name

Return Values

[1]table a user data table formated as: {username,password,max_download,max_upload,max_download_account,max_upload_account,max_connection,connect_timeout,idle_timeout,connect_per_ip,pass_length,show_hidden_file,change_pass,send_message,ratio_credit,ratio_download,ratio_upload,ratio_count_method,enable_ratio,current_quota,max_quota,enable_quota,note_name,note_address,note_zip,note_phone,note_fax,note_email,note_memo,{Directories table},{Ipmasks table},{Filemasks table},{Usergroups table},enable_group,enable_schedule,{Scheduler table},limit_reset_time,limit_reset_type,limit_enable_upload,cur_upload_size,max_upload_size,limit_enable_download,cur_download_size,max_download_size,enable_expire,expiretime,total_received,total_sent,login_count,file_download,file_upload,failed_download,failed_upload,last_loginip,last_logintime,protocol_type,enable_password,enable_account,ssh_pubkey_path,enable_ssh_pubkey_auth,ssh_auth_method,enable_weblink,enable_uplink,enable_two_factor,two_factor_code,extra_info,{Subfolder rules table} }

Remarks

Return a table of user data.

c_DeleteUser(string strDomain, string strUsername)

Parameters

[1]string the domain name

[2]string the user name

Return Values

nil

Remarks

Delete a user account.

c_CopyUser(string strDomain, string strUsername, string strNewUsername)

Parameters

[1]string the domain name

[2]string the source user name

[3]string the new user name

Return Values

[1]int the result code, 1=success, -1=source user not exists, -2=new user already exists.

Remarks

Copy a user account.

c_AddUserDirectory(string strDomain,string strUsername, string strDirectory,string strAlias,bool bIsHomeDir,bool bFileRead,bool bFileWrite,bool bFileAppend,bool bFileDelete,bool bDirectoryList,bool bDirectoryMake,bool bDirectoryDelete,bool bDirectoryRename,bool bFileRename,bool bZipFile,bool bUnzipFile)

Parameters

[1]string the domain name

[2]string the user name

[3]string the directory path

[4]string the directory alias, "/" is for home directory

[5]bool is home directory?

[6]bool can download files?

[7]bool can upload files?

[8]bool can resume file uploading?

[9]bool can delete files?

[10]bool can see the file listing?

[11]bool can make a directory?

[12]bool can remove a directory?

[13]bool can rename a directory?

[14]bool can rename a file?

[15]bool can zip files?

[16]bool can unzip file?

[16]bool can user unzip a zip file?

Return Values

nil

Remarks

Add a home/virtual directory for user account.

c_ResetUserStatistic(string strDomain, string strUsername)

Parameters

[1]string the domain name

[2]string the user name

Return Values

nil

Remarks

Reset user's statistics.

c_RemoveUserCache(string strDomain, string strUsername)

Parameters

[1]string the domain name

[2]string the user name

Return Values

nil

Remarks

Remove related user's cache. When using MySQL/ODBC database, the loaded user data won't be updated immediately if you modify the database record directly. So you need to use this API to remove the user cache.

c_GetUserList(string strDomain)

Parameters

[1]string the domain name

Return Values

[1]string user list string

Remarks

Returns user list, username in the list is separated with a carriage return sign.

c_GetUserListPage(string strDomain, int nPageNum)

Parameters

[1]string the domain name

[2]int the page number

Return Values

[1]string user list string

Remarks

This function is similar to c_GetUserList(), this API will be used when storing user data via database, and the 2nd parameter tells records offset (100 records/page, 0=1~100, 1=101~200...).

c_GetUserPageCount(string strDomain)

Parameters

[1]string the domain name

Return Values

[1]int the total records of users

[2]int the total pages (100 records per page)

Remarks

Returns the total records of users in database, and the total pages (100 records per page).

c_AddGroup(string strDomain,string strGroupname, int nMaxDownloadSpeed,int nMaxUploadSpeed,int nMaxConnection,int nConnectTimeout,int nIdleTimeout,int nConnectPerIp,int nConnectPerUser,int nConnectPerIpForUser,int bShowHiddenFile,int bSendMessage,table tabUserDirectory, table tabUserIpmasks, table tabUserFilemasks, int nMaxDownloadSpeedPerUser,int nMaxUploadSpeedPerUser,int nMaxDownloadSpeedPerGroup,int nMaxUploadSpeedPerGroup, table tabUserList, table tabSubfolderPerm)

Parameters

[1]string the domain name

[2]string the group name

[3]int max download speed for one session

[4]int max upload speed for one session

[5]int max number of connections

[6]int ftp connect timeout value

[7]int ftp idle timeout value

[8]int max number of connections per IP for group

[9]int max number of connections per user account

[10]int max number of connections per IP for user account

[11]int whether to show the hidden file, 1=show, 0=hide

[12]int whether to send message, 1=allow, 0=deny

[13]table a table list of group directory, {group directory} is a table structure which is formated as: {m_strDir,m_strAlias,m_bIsHomeDir,m_bFileRead,m_bFileWrite,m_bFileAppend,m_bFileDelete,m_bDirectoryList,m_bDirectoryMake,m_bDirectoryDelete,m_bDirectoryRename,m_bFileRename,m_bZipFile,m_bUnzipFile}

[14]table a table list of group ipmask, {group ipmask} is a table structure which is formated as: {m_strIp,m_bRefuse}

[15]table a table list of group filemask, {group filemask} is a table structure which is formated as: {m_strMask,m_bRefuse}

[16]int max download speed for specified user

[17]int max upload speed for specified user

[18]int max download speed for this group

[19]int max upload speed for this group

[20]table userlist belong to this group, like { {"aa"}, {"bb"}, {"cc"} }

[21]table subfolder access rules

Return Values

nil

Remarks

Add or modify a user group.

c_GroupExist(string strDomain, string strGroupname)

Parameters

[1]string the domain name

[2]string the group name

Return Values

[1]bool return true if the specified group exists in the specified domain, otherwise return false

Remarks

Check whether the specified group exists.

c_GetGroup(string strDomain, string strGroupname)

Parameters

[1]string the domain name

[2]string the group name

Return Values

[1]table a table of group, its structure is formated as: {groupname,max_download,max_upload,max_download_account,max_upload_account,max_connection,connect_timeout, idle_timeout,connect_per_ip, max_session_per_user, max_ipsession_for_user, show_hidden_file,send_message,{directory table},{Ipmask table},{Fil emask table}, total_received, total_sent, login_count, file_download, file_upload, failed_download, failed_upload,{Userlist table},{Subfolder rules table} }

Remarks

Return a table of group data.

c_DeleteGroup(string strDomain, string strGroupname)

Parameters

[1]string the domain name

[2]string the group name

Return Values

nil

Remarks

Delete a group.

c_CopyGroup(string strDomain, string strGroupname, string strNewGroupname)

Parameters

[1]string the domain name

[2]string the source group name

[3]string the new group name

Return Values

[1]int the result code, 1=success, -1=source group not exists, -2=new group already exists.

Remarks

Copy a group.

c_AddGroupDirectory(string strDomain,string strGroupname, string strDirectory,string strAlias,bool bIsHomeDir,bool bFileRead,bool bFileWrite,bool bFileAppend,bool bFileDelete,bool bDirectoryList,bool bDirectoryMake,bool bDirectoryDelete,bool bDirectoryRename,bool bFileRename,bool bZipFile,bool bUnzipFile)

Parameters

[1]string the domain name

[2]string the group name

[3]string the directory path

[4]string the directory alias, "/" is for home directory

[5]bool is home directory?

[6]bool can download files?

[7]bool can upload files?

[8]bool can resume file uploading?

[9]bool can delete files?

[10]bool can see the file listing?

[11]bool can make a directory?

[12]bool can remove a directory?

[13]bool can rename a directory?

[14]bool can rename a file?

[15]bool can zip files?

[16]bool can unzip file?

Return Values

nil

Remarks

Add a virtual directory for a group.

c_ResetGroupStatistic(string strDomain, string strGroupname)

Parameters

[1]string the domain name

[2]string the group name

Return Values

nil

Remarks

Reset group's statistics.

c_GetGroupList(string strDomain)

Parameters

[1]string the domain name

Return Values

[1]string group list string

Remarks

Returns the group list, and group name in the list is separated with a carriage return sign.

c_GetGroupListPage(string strDomain, int nPageNum)

Parameters

[1]string the domain name

[2]int the page number

Return Values

[1]string group list string

Remarks

This function is similar to c_GetGroupList(), this API will be used when storing group data via database, and the 2nd parameter tells records offset (100 records/page, 0=1~100, 1=101~200...).

c_GetGroupPageCount(string strDomain)

Parameters

[1]string the domain name

Return Values

[1]int the total records of groups

[2]int the total pages (100 records per page)

Remarks

Returns the total records of groups in database, and the total pages (100 records per page).