Method: get\_users\_in\_groups(groupname)
Purpose: Gets all members from group and any nested groups' members.

English translation of method:

```
get group information
if group has members, 
    add members to users[]
end
If group has nested_groups,
    for nested_group in nested_groups
        get nested_groupname
        get_users_in_groups(nested_groupname)
    end
end

```

Currently I pass the users array in the method attributes. However, this doesn't seem like the proper way to access an array in a recursive method.

What is the best way to add members to the users array through my recursive method?

I think I might have found a solution.

```
users = []
get group information
if group has members, 
   users.concat( members[] )
end
If group has nested_groups,
    for nested_group in nested_groups
        get nested_groupname
        users.concat( get_users_in_groups(nested_groupname) )
    end
end
users.uniq

```

Is this the best way to do this?

Sorry about that I meant to include one!

isc-staff
nested-groups: isc-admins, isc-teachers, isc-paras
members: none

isc-admins
nested-groups: none
members: adminone, admintwo

isc-teachers
nested-groups: sped-teachers
members: teacherone, teachertwo

isc-paras
nested-groups: none
members: paraone, paratwo

sped-teachers
nested-groups: none
members: spedteacherone, spedteachertwo

So my method looks up isc-staff, sees that it has isc-admins, isc-teachers, and isc-paras but no members, it needs to run itself on isc-admins, isc-teachers, and isc-paras.
When it runs on isc-admins it should add the members to users[]
When it runs on isc-teachers it should add the members to users[] and run itself through sped-teachers

This information isn't stored in an array, it has to be pulled from LDAP.

Is that enough information?

The structure would look something similar to

```
{
 group_name: 'isc-staff',
 nested_groups: [
                 {
                  group_name: 'isc-admins',
                  members: ['adminone', 'admintwo']
                 },
                 {
                  group_name: 'isc-teachers',
                  members: ['teacherone', 'teachertwo'],
                  nested_groups: [
                                  {
                                   group_name: 'sped-teachers',
                                   members: ['spedteacherone']
                                  }
                                 ]
                 },
                 {
                  group_name: 'isc-paras',
                  members: ['paraone', 'paratwo']
                 }
 ]
}

```

Result should be:

```
['adminone','admintwo','teacherone','teachertwo','spedteacherone','paraone','paratwo']

```