SharePoint の "モダン" サイトの分類

注:

サイト分類の代わりに秘密度ラベル (/microsoft-365/compliance/sensitivity-labels-teams-groups-sites) を使用して、SharePoint サイトを保護できるようになりました。

SharePoint Online で "モダン" サイトを作成するときに、オプションとして [サイトの分類] を選択し、サイト データの秘密度を定義できます。 サイト分類の目標は、ガバナンスと法令遵守のパースペクティブからの分類に基づいてサイトのクラスターを管理したり、サイト分類に基づいてガバナンス プロセスを自動化したりできるようにすることです。

重要

[サイトの分類] オプションは既定では無効です。Azure AD レベルでこれを構成する必要があります。

テナントで [サイトの分類] を有効にする

[サイトの分類] を利用するには、ターゲット テナントでこの機能を Azure AD レベルにおいて有効にする必要があります。 この機能を有効にすると、"モダン" サイトの新規作成中に、[データの機密性の程度] という追加のフィールドが表示されます。 サイトの分類のフィールドが、次の図に示されているように表示されます。

SharePoint Online での


次の図にあるように、"モダン" サイトの見出しに分類が強調表示されます。

PowerShell で [サイトの分類] を有効にする

[サイトの分類] 機能を有効にするには、次のサンプルのような PowerShell コードを実行できます。

# Install the Azure AD Preview Module for PowerShell
Install-Module AzureADPreview

# Connect to Azure AD
Connect-AzureAD

# Create new directory setting and set initial values
$template = Get-AzureADDirectorySettingTemplate | where { $_.DisplayName -eq "Group.Unified" }

$setting = $template.CreateDirectorySetting()
$setting["UsageGuidelinesUrl"] = "https://aka.ms/sppnp"
$setting["ClassificationList"] = "HBI, MBI, LBI, GDPR"
$setting["DefaultClassification"] = "MBI"
New-AzureADDirectorySetting -DirectorySetting $setting

注:

Office 365 の UI でこの設定が有効になるまでに約 1 時間以上かかることに注意してください。

前述のコード スニペットに関して、この資料を書いている時点では Azure AD コマンドレットのプレビュー版を使用する必要がありますが、間もなく RTM バージョンが使用可能になります。 Azure AD コマンドレットをインストールした後は、Azure AD ターゲット テナントに接続するだけで済みます。このテナントが SharePoint Online ターゲット テナントの背後に配置されます。

Get-AzureADDirectorySettingTemplate コマンドレットを使用して、(DisplayNameGroup.Unified である) 統合グループ設定テンプレートへの参照を取得します。

テンプレートの取得後、そのテンプレートの設定を構成できます。これを行うには、新しい DirectorySetting を作成し、ディクショナリを介して設定値を提供します。

[サイトの分類] パースペクティブから可能な主な設定は次のとおりです。

  • UsageGuidelinesUrl:さまざまな分類オプションについて記述できるページの URL。 そのページへのリンクが、サイト作成フォームと、分類された各サイトの見出しに表示されます。
  • ClassificationList:[サイトの分類] オプション一覧を示す、コンマ区切りの値リスト。
  • DefaultClassification:[サイトの分類] の既定値。

PnP コア ライブラリで [サイトの分類] を有効にする

[サイトの分類] 機能を有効にするための別の選択肢として、PnP コア ライブラリを利用できます。このライブラリには、C# コードで分類を管理する拡張メソッドがいくつかあります。

たとえば、[サイトの分類] を有効にするには、次のような C# コードを記述できます。

// Connect to the admin central of your tenant
using (var adminContext = new ClientContext("https://[tenant]-admin.sharepoint.com/"))
{
    // Provide a valid set of credentials
    adminContext.Credentials = OfficeDevPnP.Core.Utilities.CredentialManager.GetSharePointOnlineCredential("[name-of-your-credentials]");

    // Create a new instance of the Tenant class of CSOM
    var tenant = new Tenant(adminContext);

    // Get an Azure AD Access Token using ADAL, MSAL, or whatever else you like
    var accessToken = getAzureADAccessToken();

    // Define the list of classifications
    var newClassificationList = new List<String>();
    newClassificationList.Add("HBI");
    newClassificationList.Add("MBI");
    newClassificationList.Add("LBI");
    newClassificationList.Add("GDPR");

    // Use the PnP extension method to enable site classification
    // Including a default classification value and the URL to an informative page
    tenant.EnableSiteClassifications(accessToken, newClassificationList, "MBI", "https://aka.ms/OfficeDevPnP");
}

テナントで [サイトの分類] を更新または削除する

[サイトの分類] を有効にする場合と同様に、PowerShell または PnP コア ライブラリを使用して設定を更新または削除できます。

PowerShell で [サイトの分類] を更新または削除する

後で [サイトの分類] 設定を更新する必要が生じた場合、次の PowerShell スニペットを使用できます。

# Connect to Azure AD
Connect-AzureAD

# Read current settings
(Get-AzureADDirectorySetting | where { $_.DisplayName -eq "Group.Unified" }).Values

# Update settings
$currentSettings = Get-AzureADDirectorySetting | where { $_.DisplayName -eq "Group.Unified" }
$currentSettings["UsageGuidelinesUrl"] = "https://aka.ms/sppnp"
$currentSettings["ClassificationList"] = "HBI, MBI, LBI, GDPR"
$currentSettings["DefaultClassification"] = "MBI"
Set-AzureADDirectorySetting -Id $currentSettings.Id -DirectorySetting $currentSettings

注:

Office 365 の UI で設定の更新が反映されるまでに、約 1 時間以上かかる場合があります。

示されているように、DisplayName の値が Group.Unified である Directory Setting を検索し、Set-AzureADDirectorySetting コマンドレットを使ってその設定値を更新し、変更を適用できます。

[サイトの分類] を削除するには、次のコード スニペットのように Remove-AzureADDirectorySetting コマンドレットを使用できます。

# Delete settings
$currentSettings = Get-AzureADDirectorySetting | where { $_.DisplayName -eq "Group.Unified" }
Remove-AzureADDirectorySetting -Id $currentSettings.Id

PnP コア ライブラリで [サイトの分類] を更新または削除する

別の選択肢として、PnP コア ライブラリを使用できます。

たとえば、[サイトの分類] を更新するには、次のような C# コードを記述できます。

// Connect to the admin central of your tenant
using (var adminContext = new ClientContext("https://[tenant]-admin.sharepoint.com/"))
{
    // Provide a valid set of credentials
    adminContext.Credentials = OfficeDevPnP.Core.Utilities.CredentialManager.GetSharePointOnlineCredential("[name-of-your-credentials]");

    // Create a new instance of the Tenant class of CSOM
    var tenant = new Tenant(adminContext);

    // Get an Azure AD Access Token using ADAL, MSAL, or whatever else you like
    var accessToken = getAzureADAccessToken();

    // Retrieve the current set of values for site classification
    var classificationList = tenant.GetSiteClassificationList(accessToken);
    
    // And update it by adding a new value
    var updatedClassificationList = new List<String>(classificationList);
    updatedClassificationList.Add("TopSecret");

    // Update the site classification settings accordingly
    tenant.UpdateSiteClassificationSettings(accessToken, updatedClassificationList, "MBI", "https://aka.ms/SharePointPnP");
}

さらに、[サイトの分類] 設定を無効にして削除するには、次のようなコード スニペットを使用できます。

// Connect to the admin central of your tenant
using (var adminContext = new ClientContext("https://[tenant]-admin.sharepoint.com/"))
{
    // Provide a valid set of credentials
    adminContext.Credentials = OfficeDevPnP.Core.Utilities.CredentialManager.GetSharePointOnlineCredential("[name-of-your-credentials]");

    // Create a new instance of the Tenant class of CSOM
    var tenant = new Tenant(adminContext);

    // Get an Azure AD Access Token using ADAL, MSAL, or whatever else you like
    var accessToken = getAzureADAccessToken();

    // Disable the site classification settings
    tenant.DisableSiteClassifications(accessToken);
}

サイトの分類を管理する

次の図に示されているように、SharePoint Online の UI を使用して [サイトの情報] 設定を編集することで、サイトの分類値をあとで読み取ったり更新したりできます。

SharePoint Online で

プログラムを使用してサイトの分類を読み取る

開発者の観点から、SharePoint Online の CSOM と REST API を使用して、特定のサイトの分類値を読み取ったり書き込んだりできます。 実際、すべての SharePoint Online サイト コレクションに含まれている Classification プロパティを使用すると、サイトの分類を読み取ることができます。

そのための PowerShell スニペットを次に示します。

# Delete settings
Connect-PnPOnline "https://[tenant].sharepoint.com/sites/[modernsite]" -Credentials [credentials]

$site = Get-PnPSite
$classificationValue = Get-PnPProperty -ClientObject $site -Property Classification
Write-Host $classificationValue

(たとえば、SharePoint Framework のクライアント側の Web パーツで) REST を使用して [サイトの分類] を読み取る場合、次の REST エンドポイントを使用できます。

https://[tenant].sharepoint.com/sites/[modernsite]/_api/site/Classification

サイトの分類値に基づいて、オートメーションとカスタム ポリシー ルールを定義できます。

PnP コア ライブラリには、CSOM のサイト オブジェクト用の拡張メソッドがあり、これによりサイトの分類値を簡単に読み取ることができます。 次のコード スニペットで、この拡張メソッドを利用する方法を示します。

// Connect to the target site collectiion
using (var clientContext = new ClientContext("https://[tenant].sharepoint.com/sites/[modernsite]"))
{
    // Provide a valid set of credentials
    clientContext.Credentials = OfficeDevPnP.Core.Utilities.CredentialManager.GetSharePointOnlineCredential("[name-of-your-credentials]");

    // Read the current classification value
    var currentClassification = clientContext.Site.GetSiteClassification();
}

プログラムを使用してサイトの分類を更新する

ターゲットが "モダン" 通信サイトの場合は、CSOM の Classification プロパティを使用して値を更新することもできます。

ターゲットが "モダン" チーム サイトで、分類の値を更新する場合は、Microsoft Graph を使用する必要があります。CSOM の Classification プロパティは Microsoft 365 グループの classification プロパティの値を複製するだけだからです。

注:

Microsoft Graph を使用して Microsoft 365 グループを更新する方法の詳細については、「グループを更新する」をご覧ください。

PnP コア ライブラリにある拡張メソッドは "モダン" サイトの種類に応じて適切な動作を適用し、これによりサイトの分類を簡単に更新できます。 次のコードの引用部分で、その使用方法を示します。

// Connect to the target site collectiion
using (var clientContext = new ClientContext("https://[tenant].sharepoint.com/sites/[modernsite]"))
{
    // Provide a valid set of credentials
    clientContext.Credentials = OfficeDevPnP.Core.Utilities.CredentialManager.GetSharePointOnlineCredential("[name-of-your-credentials]");

    // Get an Azure AD Access Token using ADAL, MSAL, or whatever else you like
    // This is needed only if your target is a "modern" team site
    var accessToken = getAzureADAccessToken();

    // Update the classification value, where the accessToken is an optional argument
    clientContext.Site.SetSiteClassification("MBI", accessToken);

    // Read back the new classification value (it can take a while to get back the new value)
    var currentClassification = clientContext.Site.GetSiteClassification();
}

関連項目