Expired User List
-
- Posts: 6
- Joined: Tue Aug 07, 2012 3:08 pm
Expired User List
Is there an easy way to pull a list of all expired user accounts on a domain?
-
- Site Admin
- Posts: 2087
- Joined: Tue Sep 29, 2009 6:09 am
Re: Expired User List
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
-
- Posts: 6
- Joined: Tue Aug 07, 2012 3:08 pm
Re: Expired User List
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?
-
- Site Admin
- Posts: 2087
- Joined: Tue Sep 29, 2009 6:09 am
Re: Expired User List
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
-
- Posts: 3
- Joined: Tue Apr 09, 2013 10:37 pm
Re: Expired User List
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?
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?
-
- Site Admin
- Posts: 2087
- Joined: Tue Sep 29, 2009 6:09 am
Re: Expired User List
I have tested it, there is no problem, please make sure your domain name is correct.
-
- Posts: 3
- Joined: Tue Apr 09, 2013 10:37 pm
Re: Expired User List
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
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
-
- Posts: 3
- Joined: Tue Apr 09, 2013 10:37 pm
Re: Expired User List
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.
-
- Site Admin
- Posts: 2087
- Joined: Tue Sep 29, 2009 6:09 am
Re: Expired User List
Great! Thanks for your response!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.