LUA Script for Logins older than 180 Days

You can share your Lua Scripts with everybody here.
Post Reply
neefstumme
Posts: 2
Joined: Fri Jun 26, 2015 8:18 am

LUA Script for Logins older than 180 Days

Post by neefstumme »

Hallo,

I'm looking for a script to me all users within a group whose access more than 180 days old is outputting . The result I would then send them by mail . Is such a thing possible ?
FTP
Site Admin
Posts: 2072
Joined: Tue Sep 29, 2009 6:09 am

Re: LUA Script for Logins older than 180 Days

Post by FTP »

Code: Select all

do 
   local domain = "demo"
   local strUserlist = c_GetUserList(domain) 
   local userlist = Split(strUserlist, "\n") 

   for _,username in pairs(userlist) do 
      local user = c_GetUser(domain, username)
      local logintime = user.last_logintime
      local logintime_t = c_TranslateTime(logintime)
      if (os.time() - logintime_t) >= 3600*24*180 then 
         local userEmail = user.note_email
         c_SendMail(userEmail,"FTP Account Expiration Alert","Dear FTP user,\r\n\r\n Your FTP account will be expired soon, please login the FTP server as soon as possible!","","SMTP_CONFIG")
      end 
   end

end

Here, "SMTP_CONFIG" is your SMTP configuration name under "Servers -> Settings -> SMTP Manager".
And, you also need to define the user email address at "Edit User -> Notes -> Email address".
neefstumme
Posts: 2
Joined: Fri Jun 26, 2015 8:18 am

Re: LUA Script for Logins older than 180 Days

Post by neefstumme »

Hallo,

thanks for posting. Works great, but I only want this for a Group of Users from a Domain.
vitokk
Posts: 2
Joined: Fri Jan 19, 2018 6:00 am

Re: LUA Script for Logins older than 180 Days

Post by vitokk »

Hi, Is it possible to display a list of users who have not logged in for 180 days? Not send them info but show on screen or save to file.
Post Reply