Page 1 of 1

Problem with adding users through command line

Posted: Mon Nov 23, 2009 12:37 pm
by mellul
Hi,

I have successfully added a user through the command line:

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)

I am having a few problems though. Each time I add a user this way, the directory never gets set up. Also after I manually set up the directory and try to enter the ftp, it says: username and password not matched. When I disable the password, I enter the ftp with no problems at all.

To sum up I have 2 problems:
1) although I specify the password in the add user, it does not seem to be taken. (I try and change the password manually but to no effect)
2) the directory is not being inputted when adding a user through command line.

When I add a user through the GUI, there are no problems.

Thanks in advance for your help

Re: Problem with adding users through command line

Posted: Mon Nov 23, 2009 12:48 pm
by mellul
I would also like to add, to troubleshoot this problem I have been trying to use c_GetUser(string strDomain,string strUsername). Unfortunately I cant seem to be able to print out the table from this output using LUA so I could check what password is being stored.

I am using the following command:

print(c_GetUser('test','test'))

the output given is:

[table value]

How can I see the contents of the table?

Re: Problem with adding users through command line

Posted: Mon Nov 23, 2009 1:15 pm
by FTP
The first question, parameter "password" must be encrypted with md5, so I sugguest you write lua scripts like this:
c_AddUser(domain,username, md5(password), 63, 1, 1)
c_AddUserDirectory(domain, username, homedir, '/', true, 1,1,0,0,1,0,0,0)

The second question, you may use function "var_dump" to show all the items of a table:
var_dump(c_GetUser("test","test"))

Re: Problem with adding users through command line

Posted: Mon Nov 23, 2009 1:48 pm
by mellul
Thanks :) I wasn't adding the md5('password'). now all works great.

Thanks again

Re: Problem with adding users through command line

Posted: Tue Nov 24, 2009 9:05 am
by mellul
One other small question kind of related to this. I am trying to use a function that returns a boolean but all I seem to get from it is [boolean value]. How can I get an output of true or false?

Also, would you be able to help me with using the output from Lua in an ASP script?

Thanks

Re: Problem with adding users through command line

Posted: Tue Nov 24, 2009 9:55 am
by FTP
Hi,

I think you may use "tostring()" to show the boolean value. For example:

local bValue = true
print(tostring(bValue))

Re: Problem with adding users through command line

Posted: Tue Nov 24, 2009 9:58 am
by mellul
That seems to work. Thanks

I have edited my last question though as I need to use that output in an asp script and I am not sure how to do that. Is this possible? How can we handle the return values of these options such as c_UserExist?

Thanks again for all your help

Re: Problem with adding users through command line

Posted: Tue Nov 24, 2009 10:14 am
by FTP
It is possible, code like this:

Set xmlHttp = CreateObject("MSXML2.ServerXMLHTTP")
strUrl = "http://127.0.0.1:5466/admin_webservice.html"
strUrlParam = "?admin=demo&pass=demo&cmd="
strLuaScript = "print(tostring(c_UserExist("domain","username")))"
xmlHttp.open "GET", strUrl&strUrlParam&URLEncode(strLuaScript), False
xmlHttp.send
strResult = xmlHttp.responseText
if strResult = "true" then
Response.Write("User Existed!")
end if


Function URLEncode(strInput)
For i = 1 To Len(strInput)
intAscii = Asc(Mid(strInput, i, 1))
If ((intAscii < 58) And (intAscii > 47)) Or ((intAscii < 91) And (intAscii > 64)) Or ((intAscii < 123) And (intAscii > 96)) Then
strOutput = strOutput & Chr(intAscii)
Else
If intAscii < 16 Then
strOutput = strOutput & "%0" & Trim(Hex(intAscii))
Else
strOutput = strOutput & "%" & Trim(Hex(intAscii))
End If
End If
Next
URLEncode = strOutput
End Function

Re: Problem with adding users through command line

Posted: Tue Nov 24, 2009 11:16 am
by mellul
Thanks :) it worked great... I had everything done except for the strResult = xmlHttp.responseText and the if statement that was needed.

Thanks again