Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Learn how to associate a system user with a security role by using the Associate
message or method.
Related articles:
About the sample code
Sample | Description | Build target |
---|---|---|
AssociateSecurityRoleToUser | Demonstrates associating a user with a role. | .NET 9 |
The code sample demonstrates how to associate a system user with a security role. Specifically, the samples demonstrate how to:
- Connect to Dataverse using a connection string that defines required connection information
- Query for a security role using its name attribute.
- Associate the logged on user with that security role.
Additional information can be found in README-code-design file.
How to build and run the code sample
- Clone the PowerApps-Samples repository.
- Locate the sample folder.
- Open the solution file (*.sln) in Visual Studio.
- Edit the project's appsettings.json file and set the
Url
value as appropriate for your Dataverse test environment. - Build and run the project [F5].
- You'll be prompted in a browser window for account sign-in credentials to the target environment.
Expected program output
For a successful run, the program's console output should look similar to the following example. Otherwise, any errors or exceptions are displayed.
Discovering who you are...done.
Associating your system user record with role 'Basic User'..done.
Use the Power Platform admin center to see that you now have
the 'Basic User' role. Afterwards, remove the role if desired.
Press any key to undo environment data changes.