A brief google leads to this node, which deals with listing a user's secondary groups, you can adapt the answers from there to suit your needs. The primary group of a user can be retrieved with getpwent. You may also want to use User::pwent and User::grent for a nicer interface to those functions.
In reply to Re^3: count of USER UNIX groups
by Anonymous Monk
in thread count of USER UNIX groups
by Apronline
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |