Not
Bu sayfaya erişim yetkilendirme gerektiriyor. Oturum açmayı veya dizinleri değiştirmeyi deneyebilirsiniz.
Bu sayfaya erişim yetkilendirme gerektiriyor. Dizinleri değiştirmeyi deneyebilirsiniz.
Bu hızlı başlangıçta, etiket ilkesinin gerekçe gerektirdiği durumlarda düşürme etiketi işleminin nasıl ele alınması gerektiği ele alınmaktadır. Burada, bir dosyanın etiketlerini değiştirmek için sınıfını kullanacağız mip::FileHandler . Daha fazla ayrıntı için Microsoft Information Protection (MIP) SDK for C++: Referans'a başvurun.
Önkoşullar
Henüz yapmadıysanız devam etmeden önce aşağıdaki önkoşulları tamamladığınızdan emin olun:
- Hızlı Başlangıç: Duyarlılık etiketlerini ayarlama/alma (C++) kılavuzunu tamamlayarak başlayın. Bu, bir başlangıç Visual Studio çözümü oluşturarak, bir kuruluşun duyarlılık etiketlerini listelemek ve bir dosyaya/dosyadan duyarlılık etiketlerini ayarlamak ve okumak içindir. Bu "Nasıl yapılır - Gerekçe gerektiren bir etiketi düşürme/kaldırma (C++)" Hızlı Başlangıcı öncekini temel alır.
- İsteğe bağlı olarak: MIP SDK kavramlarındaki Dosya işleyicileri kavramlarını gözden geçirin.
Korumalı dosyaya daha düşük bir etiket ayarlamak için mantık ekleme
nesnesini kullanarak mip::FileHandler dosyada duyarlılık etiketi ayarlamak için mantık ekleyin.
Çözüm Gezgini'ni kullanarak, projenizde
main()yönteminin uygulanmasını içeren .cpp dosyasını açın. Proje oluşturma sırasında belirttiğiniz gibi, varsayılan olarak projeyi içerenle aynı ada sahiptir.Aşağıdaki #include ve kullanma yönergelerini dosyanın en üstüne ilgili mevcut yönergelerin altına ekleyin:
#include "mip/file/file_error.h" using mip::JustificationRequiredError; using std::cin;Önceki hızlı başlangıçtaki
<label-id>değeri, azaltma için gerekçe gerektiren bir duyarlılık etiketine güncelleştirin. Bu hızlı başlangıç çalıştırması sırasında önce bu etiketi ayarlayıp daha sonraki adımlarda kod parçacıkları aracılığıyla indirmeyi deneyeceğiz.Gövdenin sonuna doğru, kapatma bloğunun
main()altınasystem("pause");ve üstüne (önceki Hızlı Başlangıçta kaldığınız yer) aşağıdaki kodu ekleyin:
// Downgrade label
// Set paths and lower label ID
// Set a new label on input file.
string lowerlabelId = "<lower-label-id>";
cout << "\nApplying new Label ID " << lowerlabelId << " to " << filePathOut << endl;
mip::LabelingOptions labelingOptions(mip::AssignmentMethod::PRIVILEGED);
// Try to apply a label with lower sensitivity.
try
{
handler->SetLabel(engine->GetLabelById(lowerlabelId), labelingOptions, mip::ProtectionSettings());
}
catch (const mip::JustificationRequiredError& e)
{
// Request justification from user.
cout<<"Please provide justification for downgrading a label: "<<endl;
string justification;
cin >> justification;
// Set Justification provided flag
bool isDowngradeJustified = true;
mip::LabelingOptions labelingOptions(mip::AssignmentMethod::PRIVILEGED);
labelingOptions.SetDowngradeJustification(isDowngradeJustified,justification);
//Set new label.
handler->SetLabel(engine->GetLabelById(lowerlabelId), labelingOptions, mip::ProtectionSettings());
}
catch (const std::exception& e)
{
cout << "An exception occurred... did you specify a valid label ID?\n\n" << e.what() << "'\n";
system("pause");
return 1;
}
// Commit changes, save as a different output file
string lowerFilePathOut = "<lower-output-file-path>";
try
{
cout << "Committing changes" << endl;
auto commitPromise = std::make_shared<std::promise<bool>>();
auto commitFuture = commitPromise->get_future();
handler->CommitAsync(lowerFilePathOut, commitPromise);
if (commitFuture.get()) {
cout << "\nLabel committed to file: " << lowerFilePathOut << endl;
}
else {
cout << "Failed to label: " + lowerFilePathOut << endl;
return 1;
}
}
catch (const std::exception& e)
{
cout << "An exception occurred... did you specify a valid commit file path?\n\n" << e.what() << "'\n";
system("pause");
return 1;
}
system("pause");
// Set up async FileHandler for output file operations
string lowerActualFilePath = "<lower-content-identifier>";
try
{
auto handlerPromise = std::make_shared<std::promise<std::shared_ptr<FileHandler>>>();
auto handlerFuture = handlerPromise->get_future();
engine->CreateFileHandlerAsync(
lowerFilePathOut,
lowerActualFilePath,
true,
std::make_shared<FileHandlerObserver>(),
handlerPromise);
handler = handlerFuture.get();
}
catch (const std::exception& e)
{
cout << "An exception occurred... did you specify a valid output file path?\n\n" << e.what() << "'\n";
system("pause");
return 1;
}
// Get the lowered label from output file
try
{
cout << "\nGetting the label committed to file: " << lowerFilePathOut << endl;
auto lowerLabel = handler->GetLabel();
cout << "Name: " + lowerLabel->GetLabel()->GetName() << endl;
cout << "Id: " + lowerLabel->GetLabel()->GetId() << endl;
}
catch (const std::exception& e)
{
cout << "An exception occurred... did you specify a valid label ID?\n\n" << e.what() << "'\n";
system("pause");
return 1;
}
system("pause");
Aşağıdaki değerleri kullanarak kaynak koddaki yer tutucu değerlerini değiştirin:
Yer tutucu Değer <alt-etiket-id> Önceki Hızlı Başlangıç'taki konsol çıkışından kopyalanan etiket kimliği, örneğin: bb7ed207-046a-4caf-9826-647cff56b990. Daha önce korunan dosya etiketinden daha düşük duyarlılığa sahip olduğundan emin olun.<lower-output-file-path> Değiştirilmiş dosyayı kaydetmek istediğiniz çıkış dosyası yolu. <alt-içerik-belirteci> İçerik için insan tarafından okunabilen bir tanımlayıcı.
Uygulamayı derleme ve test etme
İstemci uygulamanızı derleyin ve test edin.
İstemci uygulamanızı derlemek için CTRL-SHIFT-B (Çözümü Derle) kullanın. Derleme hatanız yoksa, uygulamanızı çalıştırmak için F5 (Hata ayıklamayı başlat) kullanın.
Projeniz başarıyla derlenip çalıştırılırsa, SDK yönteminizi
AcquireOAuth2Token()her çağırdığında uygulama bir erişim belirteci ister.
Non-Business : 87ba5c36-17cf-14793-bbc2-bd5b3a9f95cz
Public : 83867195-f2b8-2ac2-b0b6-6bb73cb33afz
General : f42a3342-8706-4288-bd31-ebb85995028z
Confidential : 074e457c-5848-4542-9a6f-34a182080e7z
Highly Confidential : f55c2dea-db0f-47cd-8520-a52e1590fb6z
Press any key to continue . . .
Applying Label ID f55c2dea-db0f-47cd-8520-a52e1590fb6z to c:\Test\Test.docx
Committing changes
Label committed to file: c:\Test\Test.docx
Press any key to continue . . .
Run the PowerShell script to generate an access token using the following values, then copy/paste it below:
Set $authority to: https://login.microsoftonline.com/37f4583d-9985-4e7f-a1ab-71afd8b55ba0
Set $resourceUrl to: https://aadrm.com
Sign in with user account: user1@tenant.onmicrosoft.com
Enter access token: <paste-access-token-here>
Press any key to continue . . .
Getting the label committed to file: c:\Test\Test_labeled.docx
Name: Highly Confidential
Id: f55c2dea-db0f-47cd-8520-a52e1590fb6z
Press any key to continue . . .
Applying new Label ID f42a3342-8706-4288-bd31-ebb85995028z to c:\Test\Test_labeled.docx
Please provide justification for downgrading a label:
Need for sharing with wider audience.
Committing changes
Label committed to file: c:\Test\Test_downgraded.docx
Press any key to continue . . .
Getting the label committed to file: c:\Test\Test_downgraded.docx
Name: General
Id: f42a3342-8706-4288-bd31-ebb85995028z
Press any key to continue . . .
Bir dosyadan silinen etiketin etiket ilkesine göre bir gerekçe gerektirmesi durumunda, işlem için DeleteLabel() benzer bir yaklaşımın izlenmesi gerektiğini lütfen unutmayın.
DeleteLabel() işlevi bir mip::JustificationRequiredError özel durum oluşturur.
isDowngradeJustified bayrağı, etiketi başarıyla silmeden önce özel durum işlemede true olarak ayarlanmalıdır.