Need to export the list of users

You can share your Lua Scripts with everybody here.
Post Reply
mahesh.kumar
Posts: 3
Joined: Wed Dec 26, 2018 8:49 pm

Need to export the list of users

Post by mahesh.kumar »

I need to schedule a task which exports the list of users with usernames and passwords in to a file. I have seen the LUA script to delete the inactive users. But I need the list of users. Can anyone please help?
FTP
Site Admin
Posts: 2072
Joined: Tue Sep 29, 2009 6:09 am

Re: Need to export the list of users

Post by FTP »

You can't export the user password, because the user password is MD5 encrypted.
mahesh.kumar
Posts: 3
Joined: Wed Dec 26, 2018 8:49 pm

Re: Need to export the list of users

Post by mahesh.kumar »

Ok. I got that password can't be exported. I have the following script to export the username.

do
local strDomain = "mydomain"
local strUserlist = c_GetUserList(strDomain)
local userlist = Split(strUserlist,"\n")

local strResult = ""
for _,username in pairs(userlist) do
local user = c_GetUser(strDomain,username)
strResult = strResult..strDomain.."\t"..username.."\t"..user.last_logintime.."\t"..user.expiretime.."\n"
end

local fp = assert(io.open("c:/temp/MACE-user-info.txt", "wb"))
fp:write(strResult)
fp:close()
end

I created this task in the task scheduler.

Log says it executed successfully. But I can't see any output in my local file.
FTP
Site Admin
Posts: 2072
Joined: Tue Sep 29, 2009 6:09 am

Re: Need to export the list of users

Post by FTP »

OK, that Lua script has no problem, only need to replace "mydomain" into your own domain name.
Post Reply