Lua script to export user and Group membership

You can share your Lua Scripts with everybody here.
Post Reply
wuserbusiness
Posts: 2
Joined: Wed Sep 02, 2020 8:35 pm

Lua script to export user and Group membership

Post by wuserbusiness »

Hello

I have the below script I have found and edited to export a few pieces of information I need, in particular the Username and group membership of every user. But I get the error as per the below, any pointers appreciated?


some error in ... Files (x86)\Wing FTP Server\lua\ServerInterface.lua:1058: bad argument #1 to 'find' (string expected, got nil)!


Script is:


do
local strDomain = "MYDOMAIN.com"
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.."\t"..directory.dir.."\n"
end

local fp = assert(io.open("C:\wingtemp\user-info.txt", "wb"))
fp:write(strResult)
fp:close()
end

Thanks
FTP
Site Admin
Posts: 2072
Joined: Tue Sep 29, 2009 6:09 am

Re: Lua script to export user and Group membership

Post by FTP »

OK, it means no user account returned by function "c_GetUserList", maybe the domain name "MYDOMAIN.com" is wrong?
wuserbusiness
Posts: 2
Joined: Wed Sep 02, 2020 8:35 pm

Re: Lua script to export user and Group membership

Post by wuserbusiness »

Thanks, I have double checked the domain and its spelt and written as in Wing.

If i also run domainlist is shows the name specified.

Its definately failing on that part as i can run other lines ok.

Any ideas why it wint accep the domain? We are on a new build also.
Post Reply