page_type | languages | products | description | urlFragment | ||
---|---|---|---|---|---|---|
sample |
|
|
This sample application demonstrates using the Microsoft Information Protection SDK .NET wrapper to compute actions given labeling option inputs. |
MipSdk-Dotnet-Policy-Quickstart |
This sample application demonstrates using the Microsoft Information Protection SDK .NET wrapper to compute actions for a given label.
This sample illustrates basic SDK functionality where it:
- Obtains the list of labels for the user
- Prompts to input one of the label IDs
- Prompts the user to enter a second "new" label ID
- Repeatedly calls the
ComputeAction()
function until no actions remain. - Displays label actions to the screen.
This sample application illustrates using the MIP Policy API to list labels, and compute actions for a new label. All SDK actions are implemented in action.cs.
- Visual Studio 2015 or later with Visual C# development features installed
In Visual Studio 2017:
- Right-click the project and select Manage NuGet Packages
- On the Browse tab, search for Microsoft.InformationProtection.File
- Select the package and click Install
Authentication against the Azure AD tenant requires creating a native application registration. The client ID created in this step is used in a later step to generate an OAuth2 token.
Skip this step if you've already created a registration for previous sample. You may continue to use that client ID.
- Go to https://portal.azure.com and log in as a global admin.
Your tenant may permit standard users to register applications. If you aren't a global admin, you can attempt these steps, but may need to work with a tenant administrator to have an application registered or be granted access to register applications.
- Click Azure Active Directory, then App Registrations in the menu blade.
- Click View all applications
- Click New Applications Registration
- For name, enter MipSdk-Sample-Apps
- Set Application Type to Native
- For Redirect URI, enter mipsdk-auth-sample://authorize
Note: This can be anything you'd like, but should be unique in the tenant.
- Click Create
The Registered app blade should now be displayed.
- Click Settings
- Click Required Permissions
- Click Add
- Click Select an API
- Select Microsoft Rights Management Services and click Select
- Under Select Permissions select Create and access protected content for users
- Click Select then Done
- Click Add
- Click Select an API
- In the search box, type Microsoft Information Protection Sync Service then select the service and click Select
- Under Select Permissions select Read all unified policies a user has access to.
- Click Select then Done
- In the Required Permissions blade, click Grant Permissions and confirm.
- Open app.config.
- Replace YOUR CLIENT ID with the client ID copied from the AAD App Registration.
- Replace YOUR REDIRECT URI with the Redirect URI copied from the AAD App Registration.
- Replace YOUR APP NAME with the friendly name for your application.
- Replace YOUR APP VERSION with the version of your application.
Press F5 to run the sample. The console application will start and after a brief moment displays the labels available for the user.
- Copy a label ID to the clipboard.
- Paste the label in to the input prompt.
- Copy a second label to the clipboard and paste in the 2nd prompt.
- The app will compute actions and display the various protection, marking, and metadata actions to the screen.
- It's up to the calling application to understand and apply these actions.