Expired User List

Please post here if you have problems in using Wing FTP Server.
Post Reply
eneuhar
Posts: 6
Joined: Tue Aug 07, 2012 3:08 pm

Expired User List

Post by eneuhar »

Is there an easy way to pull a list of all expired user accounts on a domain?
FTP
Site Admin
Posts: 2072
Joined: Tue Sep 29, 2009 6:09 am

Re: Expired User List

Post by FTP »

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
eneuhar
Posts: 6
Joined: Tue Aug 07, 2012 3:08 pm

Re: Expired User List

Post by eneuhar »

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?
FTP
Site Admin
Posts: 2072
Joined: Tue Sep 29, 2009 6:09 am

Re: Expired User List

Post by FTP »

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
spliusko
Posts: 3
Joined: Tue Apr 09, 2013 10:37 pm

Re: Expired User List

Post by spliusko »

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?
FTP
Site Admin
Posts: 2072
Joined: Tue Sep 29, 2009 6:09 am

Re: Expired User List

Post by FTP »

I have tested it, there is no problem, please make sure your domain name is correct.
spliusko
Posts: 3
Joined: Tue Apr 09, 2013 10:37 pm

Re: Expired User List

Post by spliusko »

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

Post by spliusko »

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.
FTP
Site Admin
Posts: 2072
Joined: Tue Sep 29, 2009 6:09 am

Re: Expired User List

Post by FTP »

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!
Post Reply