OSC / ood_support

OOD Utility classes
https://osc.github.io/Open-OnDemand/
MIT License
1 stars 1 forks source link

Add group.members method #5

Open ericfranz opened 6 years ago

ericfranz commented 6 years ago

The members method would return an array of OodSupport::User objects

This is the wrapper around doing something like:

Etc.getgrnam('wiagdev').mem.map { |u| { u => Etc.getpwnam(u).gecos } }
=> [{"mrodgers"=>"Morgan Rodgers"}, {"efranz"=>"Eric Franz"}, {"an0047"=>"Eric Franz"}, {"osu10424"=>"Eric Franz"}]

If I want to get usernames and associated gecos names I could instead do this:

OodSupport::Group.new('wiagdev').members
# => [#<OodSupport::User:  username=mrodgers  gecos="Morgan Rodgers">, #<OodSupport::User:  username=efranz  gecos="Eric Franz">, #<OodSupport::User:  username=an0047  gecos="Eric Franz"> 
ericfranz commented 6 years ago

For OSC we will need to use ldapsearch for the group names instead of getgrnam