分享方式:


物件層級安全性

適用於: 應用程式擁有資料 使用者擁有資料

本文說明如何在 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 社群提問