Secondary user groups


#1

require ‘etc’
Etc.getpwnam(user)

or, using Daniel B.'s std-admin library_

require ‘sys/admin’
Sys::Admin.get_user(user)

allows me to get a struct with the user’s primary group.

However, I need to obtain the list of ALL groups that a user belongs
to (primary and secondary).
Other than doing the unportable:

groups = groups #{user}.split

is there a method in the ruby std library to get the secondary groups?


#2

On Jun 23, 6:27 pm, gga removed_email_address@domain.invalid wrote:

However, I need to obtain the list of ALL groups that a user belongs
to (primary and secondary).
Other than doing the unportable:

groups = groups #{user}.split

is there a method in the ruby std library to get the secondary groups?

Never mind. Found how to do it.


#3

On 6/23/07, gga removed_email_address@domain.invalid wrote:

However, I need to obtain the list of ALL groups that a user belongs
to (primary and secondary).
Other than doing the unportable:

groups = groups #{user}.split

is there a method in the ruby std library to get the secondary groups?

Never mind. Found how to do it.

Well how did you do it? :wink:


#4

Gregory B. wrote:

Never mind. Found how to do it.

Well how did you do it? :wink:

Here’s one way you could do it with sys-admin:

groups = []
Admin.groups{ |g|
groups << g.name if g.members.include?(‘you’)
}

Regards,

Dan