getting group logged in user belongs to

Please post here if you have problems in using Wing FTP Server.
Post Reply
seattle
Posts: 28
Joined: Tue Nov 07, 2017 7:31 pm

getting group logged in user belongs to

Post by seattle »

looking for a way that will work with the current version of getting the groups that the current user belongs to so that i can use then in a LUA script to send emails based on the group name.
FTP
Site Admin
Posts: 2072
Joined: Tue Sep 29, 2009 6:09 am

Re: getting group logged in user belongs to

Post by FTP »

OK, maybe you can get all the group names via Lua script:

Code: Select all

local user = c_GetUser("DomainName", "UserName") 
local grouplist = user["usergroups"] 

if grouplist ~= nil then 
	for _,group in pairs(grouplist) do  
		print(group.groupname.."\n")
	end
end
seattle
Posts: 28
Joined: Tue Nov 07, 2017 7:31 pm

Re: getting group logged in user belongs to

Post by seattle »

getting Failed to execute lua script of event OnUserDisconnect with the following- oops wrong line, never mind the error

Code: Select all

    local user = c_GetUser("%Domain","%Name")
    local grouplist = user["usergroups"]

    if grouplist ~= nil then
       for _,group in pairs(grouplist) do 
myfile=io.open("d://ftpusers//test.txt","a")
io.output(myfile)
io.write("ssh, %Name,  %IP, group.groupname.. \n")
io.close(myfile)

       end
    end
gives a result without the value of groupname :
ssh, courteke, 192.168.123.243, group.groupname..
FTP
Site Admin
Posts: 2072
Joined: Tue Sep 29, 2009 6:09 am

Re: getting group logged in user belongs to

Post by FTP »

You can try such Lua script:

Code: Select all

io.write("ssh, %Name,  %IP, "..group.groupname.."\n")
Post Reply