This blog post explains how to dump the flattened version of /etc/passwd and /etc/group files on a Unix system when some user and group entries are stored in a NIS (YP), LDAP or other server.
To dump these fules, run the following commands (not as root, without the leading $).
$ getent group >/tmp/group $ getent passwd >/tmp/passwd
The equivalent commands in Perl (use them if getent(1) doesn't work for you):
$ perl -le'$,=":";while(@_=getgrent){$_[3]=~y@ @,@;print@_}' >/tmp/group
$ perl -le'$,=":";while(@_=getpwent){print@_[0,1,2,3,6,7,8]}' >/tmp/passwd
For NIS (YP) users and groups only, one can use ypcat passwd and ypcat group, respectively.