Determining a User's or Group's Membership in a Group
The IADsGroup.IsMember method can be used to determine if an object is a member of a group. This method returns TRUE if the specified object is a direct member of the group, that is, the group's member property contains the specified object.
A group can contain other groups. The IADsGroup.IsMember method does not recursively verify the members of groups in its member property, groups within those groups, and so on. To recursively verify that an object is a member of a group, enumerate the groups in the member property, verify the members of those groups to see if the object is a member, and if those groups contain other groups, check their members, and so on.
Note
Since groups can be nested, group membership may have loops. Any script that enumerates over many groups should keep an internal list of groups to end recursion if a group has already been visited.