Microsoft資訊保護 SDK 提供兩個路徑,讓服務型應用程式代表其他使用者採取行動。 當檔案需要標記、保護或使用,且使用者身分識別不同於服務身分識別時,可能需要委派。 此委派的身分識別可以在 引擎 或 處理程式 層級設定,而其設定位置將取決於使用案例。
引擎設定型委派
MIP SDK 支援在所有 SDK 的設定物件中提供委派的使用者電子郵件位址;檔案、保護和原則。 這可藉由在 settings 物件上設定 DelegatedUserEmail 屬性來達成。 結果是使用該設定物件初始化的引擎會執行 所有 MIP 作業 ,就好像是提供給 DelegatedUserEmail 屬性的用戶一樣。 系統會擷取該特定用戶的原則,且所有保護作業都會以該使用者身分執行,包括成為受保護檔案的擁有者。
當您的服務為基礎的應用程式需要以使用者身分完全運作時,此模式很有用;策略必須只針對指定的使用者獲取,而且必須在使用者身分識別的情境中完成任何解密作業。 建立此引擎時,應用程式必須指定該使用者唯一的引擎識別碼,通常是郵件位址。 這可確保快取的優點將會實現。 如果未提供唯一的引擎標識碼,您的應用程式可能會遇到效能不佳。
檔案 SDK
下列範例說明如何在 C++ 和 C# 中設定檔案 SDK 應用程式的委派身分識別。 相同的模式可用於政策 SDK。
此範例示範如何在 .NET 的 File SDK 中建立 委派引擎 。
// C# Example for creating a delegated file engine
string delegatedUserEmail = "alice@contoso.com";
var engineSettings = new PolicyEngineSettings(delegatedUserEmail, authDelegate, "", "en-US")
{
// Provide the identity for service discovery.
Identity = identity,
// Set the identity for which all MIP operations will be performed.
DelegatedUserEmail = delegatedUserEmail
};
var engine = Task.Run(async () => await profile.AddEngineAsync(engineSettings)).Result;
此範例示範如何在 C++ 的檔案 SDK 中建立 委派引擎 。
// C++ Example for creating a delegated file engine
std::string delegatedUserEmail = "alice@contoso.com";
FileEngine::Settings engineSettings(delegatedUserEmail, mAuthDelegate, "", "en-US", false);
// Set the identity for which all MIP operations will be performed.
engineSettings.SetDelegatedUserEmail(delegatedUserEmail);
auto enginePromise = std::make_shared<std::promise<std::shared_ptr<FileEngine>>>();
auto engineFuture = enginePromise->get_future();
mProfile->AddEngineAsync(engineSettings, enginePromise);
mEngine = engineFuture.get();
結果是,所有檔案引擎都會代表指定的使用者建立。
處理程式型委派
在我們只需要 保護 特定使用者身分識別所屬的檔案的情況下,FileHandler 提供了一種方法,可以透過 ProtectionSettings 對象傳入使用者身分識別。 原則和任何解密作業都會以已驗證 的服務身分識別的形式執行。 保護動作將代表指定的用戶執行;該使用者將會是檔上 MIP 保護的 擁有者 。
檔案 SDK
只有直接或透過標籤套用保護的作業,才會由使用者以提供給 ProtectionSettings 對象的身分執行。 此物件會傳入 File SDK 中的 SetLabel() 或 SetProtection() 函式。
此範例示範如何在 .NET 中的檔案 SDK 中執行 委派保護作業 。
string delegatedUserEmail = "bob@contoso.com";
ProtectionSettings protectionSettings = new ProtectionSettings()
{
// Set the delegated mail address
DelegatedUserEmail = delegatedUserEmail
};
handler.SetLabel(engine.GetLabelById(options.LabelId), labelingOptions, protectionSettings);
// Similar pattern for SetProtection()
// handler.SetProtection(protectionDescriptor, protectionSettings);
此範例示範如何在 C++ 的檔案 SDK 中執行 委派保護作業 。
mip::ProtectionSettings protectionSettings;
// Set the delegated mail address
protectionSettings.SetDelegatedUserEmail(delegatedUserEmail);
handler->SetLabel(mEngine->GetLabelById(labelId), labelingOptions, protectionSettings);
結果是套用保護的所有處理程式 寫入 作業都會以委派的使用者身分執行。
保護軟體開發套件 (SDK)
保護 SDK 的運作方式與檔案 SDK 不同。 有 兩種類型的處理程式 可以建立,一種用於發佈,另一種用於取用。 與檔案 SDK 類似,委派的郵件位址是透過每個處理程式類型的 settings 對象來設定。
.NET
此範例示範如何執行 委派發佈。
string delegatedUserEmail = "bob@contoso.com";
PublishingSettings publishingSettings = new PublishingSettings(protectionDescriptor)
{
// Set the delegated mail address
DelegatedUserEmail = delegatedUserEmail
};
var protectionHandler = engine.CreateProtectionHandlerForPublishing(publishingSettings);
此範例示範如何進行 委派使用。
string delegatedUserEmail = "bob@contoso.com";
ConsumptionSettings consumptionSettings = new ConsumptionSettings(plInfo)
{
ContentName = "A few bytes.",
// Set the delegated mail address
DelegatedUserEmail = delegatedUserEmail
};
var protectionHandler = engine.CreateProtectionHandlerForConsumption(consumptionSettings);
C++
此範例示範如何執行 委派發佈。
string delegatedUserEmail = "bob@contoso.com";
mip::ProtectionHandler::PublishingSettings publishingSettings = mip::ProtectionHandler::PublishingSettings(descriptor);
// Set the delegated mail address
publishingSettings.SetDelegatedUserEmail(delegatedUserEmail);
mEngine->CreateProtectionHandlerForPublishingAsync(publishingSettings, handlerObserver, handlerPromise);
auto handler = handlerFuture.get();
此範例示範如何進行 委派使用。
string delegatedUserEmail = "bob@contoso.com";
mip::ProtectionHandler::ConsumptionSettings consumptionSettings = mip::ProtectionHandler::ConsumptionSettings(serializedPublishingLicense);
// Set the delegated mail address
consumptionSettings.SetDelegatedUserEmail(delegatedUserEmail);
mEngine->CreateProtectionHandlerForConsumptionAsync(consumptionSettings, handlerObserver, handlerPromise);
auto handler = handlerFuture.get();
必要權限
上述每個案例都需要一組不同的許可權。
| 情境 | 需要許可權 |
|---|---|
| 檔案軟體開發工具包委派引擎 | UnifiedPolicy.Tenant.Read Content.委派閱讀器 內容委派編寫器 |
| 政策 SDK 委派引擎 | UnifiedPolicy.Tenant.Read |
| 檔案 SDK 委派處理程式 | 內容委派編寫器 |
| 保護 SDK 授權發佈 | 內容委派編寫器 |
| 保護 SDK 委派耗用量 | Content.委派閱讀器 |
如需許可權的完整檢閱和設定位置,請檢閱 Microsoft資訊保護 SDK 的 API 許可權