Koozali.org: home of the SME Server

Export Users Groups

Offline Drifting

  • ****
  • 431
  • +0/-0
Export Users Groups
« 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
Infamy, Infamy, they all have it in for me!

Online ReetP

  • *
  • 3,722
  • +5/-0
Re: Export Users Groups
« Reply #1 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.


...
1. Read the Manual
2. Read the Wiki
3. Don't ask for support on Unsupported versions of software
4. I have a job, wife, and kids and do this in my spare time. If you want something fixed, please help.

Bugs are easier than you think: http://wiki.contribs.org/Bugzilla_Help

If you love SME and don't want to lose it, join in: http://wiki.contribs.org/Koozali_Foundation

Offline Jean-Philippe Pialasse

  • *
  • 2,743
  • +11/-0
  • aka Unnilennium
    • http://smeserver.pialasse.com
Re: Export Users Groups
« Reply #2 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...

Offline mmccarn

  • *
  • 2,626
  • +10/-0
Re: Export Users Groups
« Reply #3 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


Offline Drifting

  • ****
  • 431
  • +0/-0
Re: Export Users Groups
« Reply #4 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.
Infamy, Infamy, they all have it in for me!

Offline Jean-Philippe Pialasse

  • *
  • 2,743
  • +11/-0
  • aka Unnilennium
    • http://smeserver.pialasse.com
Re: Export Users Groups
« Reply #5 on: September 12, 2019, 01:15:09 PM »
Reading groups from /etc/groups you might get system groups in the way.