Page 1 of 1

Expired User List

Posted: Tue Aug 07, 2012 3:10 pm
by eneuhar
Is there an easy way to pull a list of all expired user accounts on a domain?

Re: Expired User List

Posted: Wed Aug 08, 2012 4:21 pm
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

Re: Expired User List

Posted: Wed Aug 08, 2012 6:43 pm
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?

Re: Expired User List

Posted: Thu Aug 09, 2012 1:22 pm
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

Re: Expired User List

Posted: Tue Apr 09, 2013 10:44 pm
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?

Re: Expired User List

Posted: Wed Apr 10, 2013 5:15 am
by FTP
I have tested it, there is no problem, please make sure your domain name is correct.

Re: Expired User List

Posted: Wed Apr 10, 2013 5:37 pm
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

Re: Expired User List

Posted: Wed Apr 10, 2013 5:58 pm
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.

Re: Expired User List

Posted: Thu Apr 11, 2013 6:54 am
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!