Get Users Or Members From The AD Security Group In PowerApps

Overview

 
In this blog, we will discuss how we can get the users' information from the specific Security Group in Power Apps.
 

Use Case

 
We came across a requirement wherein we need to fetch the information from AD Security Group and need to display it within Power Apps for business logic implementation.
 
Example
 
Below is one of the Security Groups created in Microsoft 365.
 
Here, there are two members added to that Security Group.
 
Get Users Or Members From The AD Security Group In PowerApps 
 
In Power Apps, I need information about those two users.
 

Steps

 
Step 1
 
Open your Power Apps Canvas App.
 
First, we need to add Office 365 Groups Connector. For that,
 
Go to View Menu, select Data sources.
 
Get Users Or Members From The AD Security Group In PowerApps 
 
Search for “Office 365 Groups”. Select the highlighted one. Add that connector in your App.
 
Get Users Or Members From The AD Security Group In PowerApps 
 
Once the Connector is added, it will look like this.
 
Get Users Or Members From The AD Security Group In PowerApps 
 
Step 2
 
Open your Power Apps screen and add a button.
 
Get Users Or Members From The AD Security Group In PowerApps
 
Write the following line of code for “OnSelect” event of the button.
  1. ClearCollect(MembersfromSG,Office365Groups.ListGroupMembers("6aa46539-17ab-494b-b566-4ecbfbd6f45b").value)  
Now, here we will store Group member information to the Power Apps collection named – “MembersfromSG”.
 
The function:
 
Office365Groups.ListGroupMembers(“Group ID”) returns the information about all the members from that security group.
 
Now, how can we find that Group ID for the Security Group?
 
There are two ways to find this.
 

Find Group ID from Azure Portal

  1. Open Azure Portal and search for Groups. This will open the following screen.

    Get Users Or Members From The AD Security Group In PowerApps

  2. Select your security group for more information.

    Get Users Or Members From The AD Security Group In PowerApps

  3. Copy Object Id. This is your Group ID.

From any SharePoint Groups

  1. Open any existing SharePoint Group of any test site.

    Get Users Or Members From The AD Security Group In PowerApps

  2. Add the Security Group as a Member for temporary purposes.

    Get Users Or Members From The AD Security Group In PowerApps

  3. Click on the name of the Security Group. Copy the Group Id from there.

    Get Users Or Members From The AD Security Group In PowerApps 
Use that Group ID in below formula. The formula will look like this.
 
Get Users Or Members From The AD Security Group In PowerApps 
  1. ClearCollect(MembersfromSG,Office365Groups.ListGroupMembers("6aa46539-17ab-494b-b566-4ecbfbd6f45b").value)  
Now, add a Gallery Control and add Collection as a data source.
 
Get Users Or Members From The AD Security Group In PowerApps
 
This will show the end-user in Gallery.
 
Step 3
 
Now, let’s run a solution.
 
This will show, User’s Display Name and User Principal Name in the Gallery.
 
Get Users Or Members From The AD Security Group In PowerApps
 
Note
The Collection returns so many useful properties. If you wish to check the name of all the returned properties go to View > Collection
 
Get Users Or Members From The AD Security Group In PowerApps
 
This will show a preview of the collection with the schema.
 
Get Users Or Members From The AD Security Group In PowerApps
 

Conclusion

 
This is how we can get the Members information using Office 365 Groups Connector in Power Apps. I hope this is clear for you now.
 
Happy Power Apping!!


Similar Articles