How to Sync MCommunity Group Members to a SharePoint List

Summary

University of Michigan's MCommunity allow users to self-manage group members, using either internal IDs (UniqNames) or external email addresses. Using MCommunity to drive filters, reporting, and access in other systems is ideal since it keeps U-M's preferred group management system as the source of truth. During the development of TrackMaster (a SharePoint-based membership tracking tool), the Depression Center saw a need to sync MCommunity group members to a contacts list in SharePoint Online, indicating for each contact the groups to which they belong.

Uploaded Image (Thumbnail)

This document presents three different sync approaches between MCommunity and SharePoint Lists that work within the security restrictions of Office 365 and Power Automate, including Microsoft's default Data Loss Prevention (DLP) policy which restricts calling 3rd-party APIs directly.
 

TL;DR: Most users will find the PHP+RSS method easiest. Feel free to use the EFDC web server in your flows.

 

Steps

Group sync via PHP and RSS

This approach uses a PHP script, hosted by ITS Shared Web Hosting servers, to act as an API proxy between MCommunity LDAP and Power Automate. Power Automate gets group membership data using the RSS connector, which is allowed by both Michigan Medicine (HITS) and University of Michigan (ITS) environments. The RSS feed is a PHP script that queries LDAP anonymously and returns the data in XML RSS feed format. This approach is approved by ITS Information Assurance but is limited to groups marked as "Public" in MCommunity (anyone with an @umich.edu address can view the list of members).

 

Architecture and data flow diagram - PHP and RSS

 

Pros and cons of PHP and RSS sync approach

Pros Cons
Approved by ITS IAM team Requires web hosting (though this is free through ITS)
Works for both internal and external group members Only allowed for "public" groups
PHP script can be customized to return other data types for other applications,
or to return non-sensitive data from systems other than MCommunity
Requires some web programming and web server knowledge
Already in use by Depression Center  

 

Setup steps

  1. Submit a request to ITS for a group AFS file share
  2. Follow the instructions in the ITS knowledge base to setup permissions and folders for shared web hosting
  3. Download the PHP script (or entire automation web API) from GitHub, and using FileZilla or Cyberduck, upload it to your group file share under: /afs/umich.edu/group/ (first letter of group name) / (group name) /Public/html/api/GetMCommunityGroupMembersRSS.php
  4. Submit a request to ITS for shared web hosting, using the AFS file share setup above
  5. Create a Power Automate flow to connect to the public URL for the web server and pass the group name in the URL. For example: https://automation.depressioncenter.org/api/GetMCommunityGroupMembersRSS.php?groupName=efdc-mobiletech@umich.edu
  6. The RSS feed will contain the list of members - both internal and external - in CSV format under the Summary field. If the query produced errors, the category will be "ERROR" instead of "SUCCESS" and the Comments field will contain the error detailsUploaded Image (Thumbnail)
    Uploaded Image (Thumbnail)
     
  7. In Power Automate, grab the CSV from the RSS Summary (or Description) field, convert it to an array, and sync with your SharePoint list accordingly
    Uploaded Image (Thumbnail)
    Uploaded Image (Thumbnail)
    Uploaded Image (Thumbnail)

     
  8. Note that in the example diagram, we use two flows - one to query RSS and save to a CSV file, and other to read the CSV file and sync to the list. This is done for example purposes only so we can re-use the same flows across different approaches. See Power Automate code here: https://github.com/DepressionCenter/TrackMaster

 

 

Group sync via Python and OneDrive

This approach uses a Python script to connect to the MCommunity API and save the a list of group members as a CSV file. OneDrive client is used to map a SharePoint document library locally, so that when Python saves the CSV files, they are automatically synced to the corresponding document library. Power Automate then picks up the CSV files from SharePoint and syncs to the appropriate list.

 

Architecture and data flow diagram - Python and OneDrive

 

Pros and cons of Python and OneDrive sync approach

Pros Cons
Works for both internal and external group members Requires virtual Windows server (though this might free through HITS)
Could allow for both Public and Private groups
(by adding running user as owner to each group)
Requires an API key for the MCommunity Groups API
(or modifying the code to use LDAP)
Python script is highly customizable, and being in a virtual server, other sync tasks could take place as well Requires some programming and windows server knowledge
Could be containerized (to run in Docker or OpenShift) by requesting an O365
"App Password" and using the Microsoft Graph API to upload the CSV files
Has not gone through ITS IA or HITS IA approval yet

 

Setup steps

  1. Get the Python code from GitHub
  2. Get an API key for "MCommunity Groups" from the ITS API team
    1. Create a "team" and an "app" in the API directory
    2. Get an API client ID and secret
  3. Modify the JSON configuration file (from GitHub)
    1. Enter the list of groups to sync
    2. Enter the API client ID and secret from the previous steps
  4. Request an Windows Server VM (virtual server) from the HITS Server team
    1. Ask for minimal specs, such as 8GB RAM and 50GB hard drive, to reduce costs
    2. Create an MCommunity group for the team members who will need access to the server, and provide the name of the group in the form
    3. Ensure these team members all have access to your SharePoint site and list
  5. Once your VM server is ready, login to the server to setup OneDrive, Python, and a Windows Scheduled Task:
    1. Install the OneDrive for Business client app
    2. Install Python and PIP
    3. Login with an account with access to the SharePoint site and list to which group members will be synced
    4. Open your SharePoint document library in Edge browser, and click the "Sync" button in the toolbarUploaded Image (Thumbnail)
       
    5. Once the library is synced to the server via OneDrive, open Windows Explorer and navigate to the folder in which you will create CSV files
    6. Copy and paste the Python and JSON scripts into this folder
    7. Open a command prompt window, and navigate to the local folder where the script resides
    8. Run the script using Python and ensure there are no error messages. There should now be CSV files in this folder containing group membersUploaded Image (Thumbnail)
       
    9. Setup a daily Windows Scheduled Task to run the Python script (run the Python executable and pass the path to the script as a parameter). Ensure the task runs under your user account
    10. Manually run the task once to ensure there are no errors. There should be new CSV files created
  6. When the setup is complete, disconnect from the server but do not log off. This is extremely important, as your account must remain logged in for OneDrive to continue syncing
  7. Create a Power Automate flow to loops through the CSV files, decodes the content (from base64), converts the file contents to an array, then syncs the array of group members to your list. See Power Automate code here: https://github.com/DepressionCenter/TrackMaster
    Uploaded Image (Thumbnail)
    Uploaded Image (Thumbnail)

    Uploaded Image (Thumbnail)

    Uploaded Image (Thumbnail)

    Uploaded Image (Thumbnail)
    Uploaded Image (Thumbnail)

 

 

Group sync via Office 365 groups

This approach lets the ITS IAM or ITS TDX iPaaS teams take care of syncing MCommunity to an Office 365 group. Power Automate can then query group members from the Office 365 group directly. This approach is approved by ITS IA, but it is limited to internal accounts (only those with a @umich.edu address).

 

Architecture and data flow diagram - O365 group sync

 

Pros and cons of Office 365 groups sync approach

Pros Cons
Least amount of setup and technical knowledge needed Works for internal group members only
(only @umich.edu addresses)
No need to worry about crossing the Firewall - all data is immediately available
inside the U-M or MM Office 365 environment
Requires ITS IAM or ITS TDX iPaaS teams to sync MCommunity groups 
to Office 365 groups, and to keep them in sync
Python script is highly customizable, and being in a virtual server,
other sync tasks could take place as well
Office 365 groups will have a different name (with a special prefix), 
which could cause some confusion when using "Share To" in O365
Approved by ITS IAM  

 

Setup Steps

  1. Submit a ticket to ITS requesting that your specific MCommunity groups get synced to Office 365 groups (ask them to refer to ticket #5150572).
  2. ITS will create the corresponding groups in Office 365 with a special prefix (which is required for their sync process to work), such as mcomm- (e.g. mcomm-efdc-mobiletech@umich.edu)
  3. Create a Power Automate flow that uses the Office 365 Groups "List groups"connector to query group members
    Uploaded Image (Thumbnail)
     
  4. Pass the Group ID from the results to a "List group members" connector
  5. Sync the results to your SharePoint list (or to a CSV file in SharePoint for a sub-flow to sync to a list). See GitHub for example flows.

 

 

Notes

  • Please note neither the Eisenberg Family Depression Center nor the Mobile Technologies Core can provide technical support for either of these solutions. This article aims to explain working sync methods that other teams can implement on a "DIY" basis. However, please reach out to your Trusted Service Provider (TSP), ITS or HITS to request support with specific steps

 

 

Resources

 

 

About the Author

Gabriel Mongefranco is a Mobile Data Architect at the University of Michigan Eisenberg Family Depression Center. Gabriel has over a decade of experience in data analytics, dashboard design, automation, back end software development, database design, middleware and API architecture, and technical writing.

 |  | 

 

Print Article

Related Articles (4)

This article explains how to check if an array of objects - in this case from a SharePoint multi-valued lookup column - contains a specific value, and what the data looks like inside Power Automate.
This article explains the Get Items action in detail, and provides several tips and tricks for filtering data from SharePoint to make Power Automate flows faster by reducing the amount of data being retrieved and leveraging SharePoint's index.
Standardized data flow for research studies that utilize mobile technologies at the University of Michigan. It depicts how data typically moves from a smart watch or wearable device, into University resources behind a firewall, and finally lands on long-term storage for preservation and analytics.
An overview of TrackMaster, a membership tracking tool built for University of Michigan and Michigan Medicine centers and institutes, by students in the U-M ITS Summer Internship program.