Décode l'informatique

Create an Active Directory (AD) account in SharePoint with Power Apps

Power Apps Se connecter à Utilisateurs Office365

Connect to SharePoint

Creating an AD account in SharePoint with Power Apps requires you to have a Person or Group type field in a SharePoint list or library. For instance with QualityAccount :

Power Apps SharePoint account of type Person
Power Apps SharePoint account of type Person

Then the SharePoint list must be connected to your Power Apps application, via the Data menu (left pane). It’s an icon which looks like a database.

Power Apps Se connecter à SharePoint
Power Apps Se connecter à SharePoint

Then, all you have to do is indicate the SharePoint site and then the list selected in the right pane.

Obtain the claims of the current user

The User() function gives some information about the current user: her email, her full name and her image. That’s all.

Unfortunately, a crucial piece of information is missing: her Claims. You will find many websites which explain that Claims can be calculated using the Concatenate() function or the & operator, with the formula:

Set(glbCurrentUserClaims;"i:0#.f|membership|" & User().Email);

In this formula, the character string “i:0#.f|membership|” is fixed. It is independent of the user or the company.

In order to avoid consuming resources unnecessarily with calling the User() function, we prefer to use a global variable glbCurrentUser which is simply defined by:

Set(glbCurrentUser;User());;

The previous formula therefore becomes:

Set(glbCurrentUserClaims;"i:0#.f|membership|" & glbCurrentUser.Email);;

This formula is valid in simple cases. In particular, if your AD (Active Directory) is perfectly “clean” and consistent. However, this is not always the case.

This is because the claim can be constructed from a user’s email address that is different from the one provided by User().Email. You will therefore need to verify this with your IT administrator.

Create the user account in SharePoint

To add a user’s AD account in the QualityAccount field, of type Person, use the following complete formula:

QualityAccount:{'@odata.type':"#Microsoft.Azure.Connectors.SharePoint.SPListExpandedUser";Claims:glbCurrentUserClaims;DisplayName:glbCurrentUser.FullName;Department:"";Email:glbCurrentUser.Email;JobTitle:"";Picture:glbCurrentUser.Picture}

Note that the Department, JobTitle and Picture fields are required for creating the account in the list. They can optionally be empty.

Another entry for the current user’s account in Power Apps.

{'@odata.type':"#Microsoft.Azure.Connectors.SharePoint.SPListExpandedUser";Claims:"i:0#.f|membership|"&User().Email;DisplayName:User().FullName;Email:User().Email;Department:"";Picture:User().Image;JobTitle:""}

Nullify a user account

To “blank” a user account in a SharePoint list, use the Blank() function 🙂

For example :

QualityAccount:{Claims:Blank();DisplayName:"";Email:"";Department:"";Picture:"";JobTitle:""}
Retrieve the email address of a claim (Claims)

The Split () and Last () functions help us:

Last(Split("i:0#.f|membership|xavier@com.fr";"|")).Result

This formula will give:

xavier@com.fr

Yep!

Microsoft365 Addict

Ajouter un commentaire