Delete user directory through REST service

You can share your Lua Scripts with everybody here.

Delete user directory through REST service

Postby jvillavi2 » Fri Feb 26, 2016 11:20 am

Hi everybody,

I was wondering if exist any function to delete user directories through the REST service.
I can see in the documentation that exist the c_AddUserDirectory function wich allows me to manually add folders with proper permits but doesn't exist a delete user directory function.
How can I do that?

Thanks
jvillavi2
 
3
 
Fri Feb 26, 2016 11:12 am

Re: Delete user directory through REST service

Postby FTP » Fri Feb 26, 2016 12:36 pm

OK, you can do it like the below code, here we use PHP for calling the RESTful web service:

Code: Select all
<?php

$strUrl = "http://127.0.0.1:5466/admin_webservice.html";
$strUrlParam = "?admin=demo&pass=demo123&cmd=";
$strLuaScript = <<<EOT
   local strDomain = "domain1"
   local strUsername = "test"
   local tableUser = c_GetUser(strDomain,strUsername)

   for k,v in pairs(tableUser) do
      if type(v) == "boolean" then
         if v == true then
            tableUser[k] = 1
         else
            tableUser[k] = 0
         end
      end
   end

   tableUser.oldpassword = tableUser.password
   tableUser.directories = {}
   AddUser(strDomain,tableUser)
EOT;

$strResult = file_get_contents($strUrl.$strUrlParam.rawurlencode($strLuaScript));
print($strResult);

?>
FTP
Site Admin
 
1876
 
Tue Sep 29, 2009 6:09 am

Re: Delete user directory through REST service

Postby jvillavi2 » Fri Feb 26, 2016 1:04 pm

Hi FTP,

Thanks for your fast answer!!

Excuse me but I'm not an expert in Lua language and I have a doubt about the script.
What is "<<<EOT" and "EOT"?
Maybe they could be the quotation marks?

Something like this:

$strLuaScript = '
local strDomain = "domain1"
local strUsername = "test"
...
AddUser(strDomain,tableUser)
';
jvillavi2
 
3
 
Fri Feb 26, 2016 11:12 am

Re: Delete user directory through REST service

Postby FTP » Fri Feb 26, 2016 1:15 pm

FTP
Site Admin
 
1876
 
Tue Sep 29, 2009 6:09 am

Re: Delete user directory through REST service

Postby jvillavi2 » Fri Feb 26, 2016 4:29 pm

Hi FTP,

Thank you very much!!
The script is working fine except one thing:

when the script is executed, the user modified can't establish a ftp connection with the wing server. Seems like the password had been changed.

Could this be possible?
jvillavi2
 
3
 
Fri Feb 26, 2016 11:12 am

Re: Delete user directory through REST service

Postby FTP » Sat Feb 27, 2016 1:46 pm

Just modified the above Lua script, please try it again.
FTP
Site Admin
 
1876
 
Tue Sep 29, 2009 6:09 am


Return to Lua scripts

Who is online

Users browsing this forum: No registered users and 2 guests