Page 1 of 1

Delete user directory through REST service

Posted: Fri Feb 26, 2016 11:20 am
by jvillavi2
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

Re: Delete user directory through REST service

Posted: Fri Feb 26, 2016 12:36 pm
by FTP
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);

?>

Re: Delete user directory through REST service

Posted: Fri Feb 26, 2016 1:04 pm
by jvillavi2
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)
';

Re: Delete user directory through REST service

Posted: Fri Feb 26, 2016 1:15 pm
by FTP
Yes, you are right, see this help document:
http://php.net/manual/en/language.types ... ax.heredoc" rel="nofollow

Re: Delete user directory through REST service

Posted: Fri Feb 26, 2016 4:29 pm
by jvillavi2
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?

Re: Delete user directory through REST service

Posted: Sat Feb 27, 2016 1:46 pm
by FTP
Just modified the above Lua script, please try it again.