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.
This quickstart shows you how to use the MIP Policy SDK to list the sensitivity labels configured for your organization.
Prerequisites
If you haven't already, be sure to complete the following prerequisites before continuing:
- Complete Quickstart: Client application initialization - Policy SDK (C++) first, which builds a starter Visual Studio solution.
- Optionally: Review Classification labels concepts.
Add logic to list the sensitivity labels
Add logic to list your organization's sensitivity labels by using the Policy engine object.
Open the Visual Studio solution you created in the previous quickstart.
In the
main()function, after the engine loads successfully, add the following code:// List sensitivity labels cout << "\nSensitivity labels for your organization:\n"; auto labels = engine->ListSensitivityLabels(); for (const auto& label : labels) { cout << label->GetName() << " : " << label->GetId() << endl; for (const auto& child : label->GetChildren()) { cout << "-> " << child->GetName() << " : " << child->GetId() << endl; } }Optionally, filter labels by content format (for example,
"email"or"file"):// List labels for email content only std::vector<std::string> contentFormats = { "email" }; auto emailLabels = engine->ListSensitivityLabels(contentFormats);
Build and test the application
Build and test your client application.
Use Ctrl+Shift+B (Build Solution) to build the application. If you don't have build errors, use F5 (Start debugging) to run.
On first run, the application prompts for authentication. Provide credentials for a user account in your tenant.
The output displays the sensitivity labels configured for your organization, similar to:
Sensitivity labels for your organization: Public : <label-id> General : <label-id> -> Anyone (unrestricted) : <label-id> Confidential : <label-id> -> All Employees : <label-id> -> Recipients Only : <label-id> Highly Confidential : <label-id> -> All Employees : <label-id> -> Recipients Only : <label-id>
Checking label behavior
You can also query label protection type information to determine how each label behaves. Starting in MIP SDK 1.18, the Label class provides methods to check the protection type:
for (const auto& label : labels)
{
cout << label->GetName();
if (label->HasDoNotForwardProtection())
cout << " [Do Not Forward]";
else if (label->HasEncryptOnlyProtection())
cout << " [Encrypt Only]";
else if (label->HasAdhocProtection())
cout << " [Custom Protection]";
cout << endl;
}
Next steps
- Compute policy actions (C++)
- Label protection types
- Classification label concepts
- Explore the MIP Policy SDK C++ sample on GitHub.