The id command has -g, -G options for groups.
That should do it?
NIS is not an issue because it’s handled inside
section 2 of the manuals. It should just work,
provided the tool you use calls getpwent() or
similar. Any decent tool will.
‘id’ is inside the ‘coreutils’ distribution if
you want to compile it yourself.