Advanced Features > Server Lua API > User & Group

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)

Parameters

[1]string the domain name

[2]string the user name

[3]string password with MD5 encryption

[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 directories (user directory also is a table, its structure 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 ipmasks (user ipmask also is a table, its structure is formated as {m_strIp,m_bRefuse}).

[34]table a table list of user filemasks list (user filemask also is a table, its structure is formated as {m_strMask,m_bRefuse}).

[35]table a table list of user groups (user group also is a table, its structure is formated as {m_strGroupname}).

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

[37]table a table list of access schedulers (access scheduler also is a table, its structure 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, its structure looks like parameter 32.

[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

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,{Subfolder Rules table}}.

Remarks

Return a table of user data if the specified user exists, otherwise return nil.

c_DeleteUser(string strDomain, string strUsername)

Parameters

[1]string the domain name

[2]string the user name

Return Values

nil

Remarks

Delete a user.

c_CopyUser(string strDomain, string strUsername, string strNewUsername)

Parameters

[1]string the domain name

[2]string the source user name

[3]string the destination user name

Return Values

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

Remarks

Copy a user.

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 alias of the directory, set "/" for home directory.

[5]bool is home directory?

[6]bool can user read files?

[7]bool can user write files?

[8]bool can user resume files uploading?

[9]bool can user delete files?

[10]bool can user see files listing?

[11]bool can user make a directory?

[12]bool can user remove a directory?

[13]bool can user rename a directory?

[14]bool can user rename a file?

[15]bool can user zip file or folder?

[16]bool can user unzip a zip file?

Return Values

nil

Remarks

Add a home directory or 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_GetUserList(string strDomain)

Parameters

[1]string the domain name

Return Values

[1]string username 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 username list string

Remarks

This function is similar to c_GetUserList(), the difference is that it will be used when storing user data via database, and the 2nd parameter tells records offset (20 records/page, 0=1~20, 1=21~40...).

c_GetUserPageCount(string strDomain)

Parameters

[1]string the domain name

Return Values

[1]int the total records of users

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

Remarks

Returns the total records of users in database, and the total pages (20 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 directories (group directory also is a table, its structure 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 ipmasks (group ipmask also is a table, its structure is formated as {m_strIp,m_bRefuse}).

[15]table a table list of group filemasks (group filemask also is a table, its structure 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, its structure looks like parameter 13

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},{Filemask table}, total_received, total_sent, login_count, file_download, file_upload, failed_download, failed_upload,{Userlist table} }.

Remarks

Return a table of group data if the specified group exists, otherwise return nil.

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 destination group name

Return Values

[1]int the result code, 1=success, -1=source group not exists, -2=destination 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 alias of the directory, set "/" for home directory.

[5]bool is home directory?

[6]bool can user read files?

[7]bool can user write files?

[8]bool can user resume files uploading?

[9]bool can user delete files?

[10]bool can user see files listing?

[11]bool can user make a directory?

[12]bool can user remove a directory?

[13]bool can user rename a directory?

[14]bool can user rename a file?

[15]bool can user zip file or folder?

[16]bool can user unzip a zip file?

Return Values

nil

Remarks

Add 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 groupname 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 groupname list string

Remarks

This function is similar to c_GetGroupList(), the difference is that it will be used when storing group data via database, and the 2nd parameter tells records offset (20 records/page, 0=1~20, 1=21~40...).

c_GetGroupPageCount(string strDomain)

Parameters

[1]string the domain name

Return Values

[1]int the total records of groups

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

Remarks

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