in reply to using perl to collect NT groups

Probably not what you are looking for but Win32::NetAdmin has GetUserGroupFromRID(server, RID, returnedName).

Retrieves the name of an alias (i.e local group) or a user group for a RID from the specified server. These functions can be used for example to get the account name for the administrator account if it is renamed or localized.