(users_dictionary, groups_dictionary, computers_dictionary, group_distinguished_name, explode_nested, base_group_name, groups_seen)
return group_dictionary
Builds group membership for a specified group.
Builds group membership for a specified group.
Builds group membership for a specified group .
def process_group(users_dictionary, groups_dictionary, computers_dictionary, group_distinguished_name, explode_nested, base_group_name, groups_seen):
    """Builds group membership for a specified group."""
    # Store assorted group information.
    group_dictionary = []

    # Query SAM name or used redefined SAM name if processing a nested group.
    if base_group_name is None:
        group_sam_name = groups_dictionary[group_distinguished_name].sam_account_name
    elif base_group_name is not None:
        group_sam_name = base_group_name

    # Add empty groups to the Domain Group Membership list for full visibility.
    if not groups_dictionary[group_distinguished_name].members:
        temp_list = [group_sam_name, '']
        group_dictionary.append(temp_list)

    # Add users/groups/computer if they are a 'memberOf' the group
    for member in groups_dictionary[group_distinguished_name].members:
        # Process users.
        if member in users_dictionary:
            user_member = users_dictionary[member]

            temp_list = [group_sam_name, user_member.sam_account_name, user_member.get_account_flags()]
            group_dictionary.append(temp_list)

        # Process computers.
        elif member in computers_dictionary:
            temp_list = [group_sam_name, computers_dictionary[member].sam_account_name]
            group_dictionary.append(temp_list)

        # Process groups.
        elif member in groups_dictionary:
            if not explode_nested or (explode_nested and base_group_name is None):
                temp_list = [group_sam_name, groups_dictionary[member].sam_account_name]
                group_dictionary.append(temp_list)

            if explode_nested:
                # Stop processing the chain if a circular reference is detected.
                if member in groups_seen:
                    pass
                # Process a nested group.
                else:
                    groups_seen.append(member)
                    group_dictionary += process_group(users_dictionary, groups_dictionary, computers_dictionary, member, True, group_sam_name, groups_seen)

    return group_dictionary
def process_group ( users_dictionary , groups_dictionary , computers_dictionary , group_distinguished_name , explode_nested , base_group_name , groups_seen ) : # Store assorted group information. group_dictionary = [ ] # Query SAM name or used redefined SAM name if processing a nested group. if base_group_name is None : group_sam_name = groups_dictionary [ group_distinguished_name ] . sam_account_name elif base_group_name is not None : group_sam_name = base_group_name # Add empty groups to the Domain Group Membership list for full visibility. if not groups_dictionary [ group_distinguished_name ] . members : temp_list = [ group_sam_name , '' ] group_dictionary . append ( temp_list ) # Add users/groups/computer if they are a 'memberOf' the group for member in groups_dictionary [ group_distinguished_name ] . members : # Process users. if member in users_dictionary : user_member = users_dictionary [ member ] temp_list = [ group_sam_name , user_member . sam_account_name , user_member . get_account_flags ( ) ] group_dictionary . append ( temp_list ) # Process computers. elif member in computers_dictionary : temp_list = [ group_sam_name , computers_dictionary [ member ] . sam_account_name ] group_dictionary . append ( temp_list ) # Process groups. elif member in groups_dictionary : if not explode_nested or ( explode_nested and base_group_name is None ) : temp_list = [ group_sam_name , groups_dictionary [ member ] . sam_account_name ] group_dictionary . append ( temp_list ) if explode_nested : # Stop processing the chain if a circular reference is detected. if member in groups_seen : pass # Process a nested group. else : groups_seen . append ( member ) group_dictionary += process_group ( users_dictionary , groups_dictionary , computers_dictionary , member , True , group_sam_name , groups_seen ) return group_dictionary