List groups with directories and users

You can share your Lua Scripts with everybody here.

List groups with directories and users

Postby vogelit » Tue Sep 07, 2021 7:56 am

Looking for a way to get a list of all groups with their assigned directories and users.
Build this, but its not really working fine.

do
local strDomain = "mydomainname"
local strGrouplist = c_GetGroupList(strDomain)
local grouplist = Split(strGrouplist,"\n")

local strResult = ""
for _,groupname in pairs(grouplist) do
local group = c_GetGroup(strDomain,groupname)
local dirlist = c_GetGroup(strDomain,groupname).directory
local userlist = c_GetGroup(strDomain,groupname).userlist
for _,user in pairs(userlist) do
print(groupname)
print("\t")
print(user.username)
print("\n")
end
end
end
vogelit
 
1
 
Tue Sep 07, 2021 7:46 am

Re: List groups with directories and users

Postby FTP » Tue Sep 07, 2021 10:00 am

OK, so please try the following Lua script:

Code: Select all
do
   local strDomain = "mydomainname"
   local strGrouplist = c_GetGroupList(strDomain)
   local grouplist = Split(strGrouplist,"\n")

   local strResult = ""
   for _,groupname in pairs(grouplist) do
      local group = c_GetGroup(strDomain,groupname)
      local dirlist = c_GetGroup(strDomain,groupname).directory
      local userlist = c_GetGroup(strDomain,groupname).userlist

      if userlist ~= nil then
         for _,user in pairs(userlist) do
            print(groupname)
            print("\t")
            print(user.username)
            print("\n")
         end
      end
   end
end
FTP
Site Admin
 
1852
 
Tue Sep 29, 2009 6:09 am


Return to Lua scripts

Who is online

Users browsing this forum: No registered users and 2 guests

cron