Muokkaa

Jaa


Sample: Disable a user

This sample shows how to disable and enable a system user account in an online or on-premise/IFD environment. Download the complete sample from Sample: Disable a User.

Note

This sample applies to both Dynamics 365 Customer Engagement (on-premises) and Dataverse.

Prerequisites

Internet connection is required to download the sample project and to restore the NuGet packages used in the sample project.

The Customer Engagement user account under which you run this program must have the System Administrator role in order to enable/disable a system user.

Before building this sample, open the solution in Visual Studio and select View > Task List. There are two TODO comments that you must follow to provide the required information about an existing system user in your organization.

Requirements

See How to run samples for information about how to run this sample.

Demonstrates

Demonstrates using SetStateRequest to disable and enable a system user. Also shows how to retrieve information about a system user.

To view the summary of the specified system user in Customer Engagement, navigate to Settings > Security > Users and select the target system user account in the list. If desired, choose the Disabled Users system view to filter the list of all users. The user's status should be "Disabled".

Example

SampleProgram.cs
SampleMethod.cs

See also

User and Team Entities
SetStateRequest