Koozali.org: home of the SME Server

Obsolete Releases => SME Server 9.x => Topic started by: Drifting on September 10, 2019, 01:27:28 PM

Title: Export Users Groups
Post by: Drifting on September 10, 2019, 01:27:28 PM
Is there a way to export the groups, and the users who have rights to those groups in a csv?
Trying to audit a system that the user has managed, trouble is he has a goodly few groups.
Not urgent, just trying to save myself time reading.

Thanks Paul
Title: Re: Export Users Groups
Post by: ReetP on September 10, 2019, 10:13:15 PM
The basic info is in the accounts db.

Code: [Select]
db accounts show
Try grepping for groups eg

Code: [Select]
db accounts show |grep =group
Then you can look for members

Code: [Select]
db accounts getprop {group} Members
I guess you can probably script that and output to csv.


Title: Re: Export Users Groups
Post by: Jean-Philippe Pialasse on September 10, 2019, 11:35:13 PM
You can use the lazy admin tools contrib to export config as text files. You will get pipe separated files for users, groups, domains...
Title: Re: Export Users Groups
Post by: mmccarn on September 11, 2019, 05:20:36 AM
list group names and members from the config db:
Code: [Select]
for g in $(db accounts show |grep '=group' |sed 's/=group//'); do printf "$g\t$(db accounts getprop $g Members)\n"; done

list groups with 1 or more members (entries that don't end with a colon) from /etc/group:
Code: [Select]
grep -v :$ /etc/group

list ibay names and their groups:
Code: [Select]
for i in $(db accounts show |grep '=ibay' |sed 's/=ibay//'); do printf "$i\t$(db accounts getprop $i Group)\n"; done

Title: Re: Export Users Groups
Post by: Drifting on September 11, 2019, 10:54:39 AM
Wow guys!

Thank you so much, was not a task I was looking forward to. As per usual it was a favour job! The joys of retirement!

Thanks again Paul.
Title: Re: Export Users Groups
Post by: Jean-Philippe Pialasse on September 12, 2019, 01:15:09 PM
Reading groups from /etc/groups you might get system groups in the way.