in reply to Fetching groups a user is in

The easiest thing to do is use the xnix (provided you are using an xnix box) command groups:
my @groups = `groups $username`; print join "\n", @groups;
This normally doesn't require any special priviledges.

Update: Then determine the GIDs of course.

"Make everything as simple as possible, but not simpler." -- Albert Einstein