物件層級安全性
適用於: 應用程式擁有數據
用戶擁有數據
本文說明如何在Power BI 應用程式中內嵌使用OLS的Power BI 內容,以擁有數據 (為客戶內嵌)案例。
在此案例中,ISV 具有敏感數據和元數據的數據表,其想要從報表客戶隱藏。
如需OLS的詳細資訊,請移至物件層級安全性 (OLS)。
必要條件
本文假設您有使用 OLS 的報表,而且您想要將它內嵌至應用程式。 若要建立使用 OLS 的報表,請參閱 物件層級安全性 (OLS) 。
您可以使用下列任何模型來建置報表:
內嵌使用物件層級安全性的報表
針對使用 OLS 的項目產生內嵌令牌的程式,與靜態 RLS 的程式相同。 您需要角色和用戶名稱。
如果您想要內嵌的報表使用下列其中一個案例,您可能需要採取一些額外的步驟:
下列範例示範如何使用 OLS 產生令牌,以隱藏具有敏感性資訊的數據表:
public EmbedToken GetEmbedToken(Guid reportId, IList<Guid> datasetIds, [Optional] Guid targetWorkspaceId)
{
PowerBIClient pbiClient = this.GetPowerBIClient();
// Defines the user identity and roles.
var olsIdentity = new EffectiveIdentity(
username: "All",
roles: new List<string>{ "SensitiveTableOLS" }, // Role created to hide a table that has sensitive information
datasets: new List<string>{ datasetId.ToString()}
);
// Create a request for getting an embed token for the OLS identity defined above
var tokenRequest = new GenerateTokenRequestV2(
reports: new List<GenerateTokenRequestV2Report>() { new GenerateTokenRequestV2Report(reportId) },
datasets: datasetIds.Select(datasetId => new GenerateTokenRequestV2Dataset(datasetId.ToString())).ToList(),
targetWorkspaces: targetWorkspaceId != Guid.Empty ? new List<GenerateTokenRequestV2TargetWorkspace>() { new GenerateTokenRequestV2TargetWorkspace(targetWorkspaceId) } : null,
identities: new List<EffectiveIdentity> { olsIdentity }
);
// Generate an embed token
var embedToken = pbiClient.EmbedToken.GenerateToken(tokenRequest);
return embedToken;
}
考量與限制
請參閱OLS模型的限制。
相關內容
Azure Analysis Services 中的物件層級安全性
更多問題嗎? 請嘗試詢問 Power BI 社群。
意見反映
https://aka.ms/ContentUserFeedback。
即將推出:我們會在 2024 年淘汰 GitHub 問題,並以全新的意見反應系統取代並作為內容意見反應的渠道。 如需更多資訊,請參閱:提交及檢視以下的意見反映: