Ensure SharePoint User with Power Automate

 I had to set custom permission and grant access to some users based on their email address. All those users were member of the organization so they exist in our Azure Active directory (AAD).




But, to set this permission, user must exist in the SharePoint information list too. So I used a function named: EnsureUser. As its name suggests, this function ensures there is a record of the current user in the user information list in the current Site collection.

To call this function with Power Automate, I used the Send HTTP request SharePoint Connector like below.



Site address: Your site address.

Method: POST

URI: _api/web/ensureuser

Header

  • Accept: application/json;odata=verbose
  • Content-Type: application/json;odata=verbose

Body: { 'logonName': 'i:0#.f|membership|jane.doe@yourDomain.com' }


If the HTTP call is successful, the output will  give you:

  • User id (from the user information list)
  • User name (property Title)
  • User email
  • UPN (User Principal Name)
  • Is admin of current site collection
  • Is Guest user.

 Then I used the User Id to set permissions.


Comments

Popular posts from this blog

How to give app access on a specific SharePoint site using Azure AD API permission

Guest user can't access Client Side Assets resources in SharePoint App Catalog site