Expired User List

Please post here if you have problems in using Wing FTP Server.

Expired User List

Postby eneuhar » Tue Aug 07, 2012 3:10 pm

Is there an easy way to pull a list of all expired user accounts on a domain?
eneuhar
 
posts 6
 
joined Tue Aug 07, 2012 3:08 pm

Re: Expired User List

Postby FTP » Wed Aug 08, 2012 4:21 pm

You can execute the following script at "Administration -> Console":

Code: Select all
local domain = "domain123"
local userlist = Split(c_GetUserList(domain), "\n")
for _,username in pairs(userlist) do
   local user = c_GetUser(domain,username)
   if user.enable_expire == true then
      local expiretime = c_TranslateTime(user.expiretime)
      local nowtime = os.time()
      if nowtime > expiretime then
         print(username)
         print("\n")
      end
   end
end
FTP
Site Admin
 
posts 1232
 
joined Tue Sep 29, 2009 6:09 am

Re: Expired User List

Postby eneuhar » Wed Aug 08, 2012 6:43 pm

Thank you very much for the code, it worked great! Would it be easy to change this a little but so that it can run in the Task Scheduler and output the information into a file?
eneuhar
 
posts 6
 
joined Tue Aug 07, 2012 3:08 pm

Re: Expired User List

Postby FTP » Thu Aug 09, 2012 1:22 pm

OK, you can use the following script:

Code: Select all
local content = ""
local domain = "domain123"
local userlist = Split(c_GetUserList(domain), "\n")
for _,username in pairs(userlist) do
   local user = c_GetUser(domain,username)
   if user.enable_expire == true then
      local expiretime = c_TranslateTime(user.expiretime)
      local nowtime = os.time()
      if nowtime > expiretime then
         content = content..username.."\n"
      end
   end
end

if content ~= "" then
   local fp = assert(io.open("c:/test.log", "wb"))
   fp:write(content)
   fp:close()
end
FTP
Site Admin
 
posts 1232
 
joined Tue Sep 29, 2009 6:09 am

Re: Expired User List

Postby spliusko » Tue Apr 09, 2013 10:44 pm

These scripts worked fine in the console, but when I tried to run them as tasks, I get the following error message:

Lua Script Error!
some error in [string "/opt/wftpserver//webadmin//admin_add_task.h..."]:20: attempt to call local 'type' (a string value)!

Do I need to modify these scripts to run as tasks?
spliusko
 
posts 3
 
joined Tue Apr 09, 2013 10:37 pm

Re: Expired User List

Postby FTP » Wed Apr 10, 2013 5:15 am

I have tested it, there is no problem, please make sure your domain name is correct.
FTP
Site Admin
 
posts 1232
 
joined Tue Sep 29, 2009 6:09 am

Re: Expired User List

Postby spliusko » Wed Apr 10, 2013 5:37 pm

Thanks for testing this so quickly.

The domain name is correct, so I'm not sure where the problem lies. I'll play with it some more.

Do you have any other innocuous test scripts I could run, to make sure it's not something outside the script that is failing?

Thanks
spliusko
 
posts 3
 
joined Tue Apr 09, 2013 10:37 pm

Re: Expired User List

Postby spliusko » Wed Apr 10, 2013 5:58 pm

Never mind. It evidently didn't like the fact that I copied and pasted the entire script. I copied and pasted the script one line at a time, and it took it without any errors.
spliusko
 
posts 3
 
joined Tue Apr 09, 2013 10:37 pm

Re: Expired User List

Postby FTP » Thu Apr 11, 2013 6:54 am

spliusko wrote:Never mind. It evidently didn't like the fact that I copied and pasted the entire script. I copied and pasted the script one line at a time, and it took it without any errors.


Great! Thanks for your response!
FTP
Site Admin
 
posts 1232
 
joined Tue Sep 29, 2009 6:09 am


Return to Support

Who is online

Users browsing this forum: Yahoo [Bot] and 2 guests