sun ldap script

We use sun ldap. I have a branch with 2500 users and 20 groups (group1, group2, group3 .. etc). I need to run a script that i can run from my solaris box that will delete all users EXCEPT the users that are members of group1. Is this possible?

Thank you in advance!