ユーザーのカスタム セキュリティ属性の割り当て、更新、一覧表示、削除

Microsoft Entra の一部である Microsoft Entra ID のカスタム セキュリティ属性は、ビジネス固有の属性 (キーと値のペア) であり、Microsoft Entra のオブジェクトに対して定義し割り当てることができます。 たとえば、カスタム セキュリティ属性を割り当てて従業員をフィルター処理したり、リソースにアクセスできるユーザーを決定したりすることができます。 この記事では、Microsoft Entra ID でのカスタム セキュリティ属性の割り当て、更新、一覧表示、削除の方法について説明します。

前提条件

Microsoft Entra テナント内のユーザーのカスタム セキュリティ属性の割り当てや削除には、次のものが必要です。

重要

既定では、グローバル管理者とその他の管理者ロールには、カスタム セキュリティ属性の読み取り、定義、割り当てを行う権限がありません。

カスタム セキュリティ属性のユーザーへの割り当て

ヒント

この記事の手順は、開始するポータルに応じて若干異なる場合があります。

  1. Microsoft Entra 管理センター属性割り当て管理者としてサインインしてください。

  2. カスタム セキュリティ属性が定義されていることを確認します。 詳細については、「Microsoft Entra ID でのカスタム セキュリティ属性定義の追加または非アクティブ化」を参照してください。

  3. [ID]>[ユーザー]>[すべてのユーザー] の順に移動します。

  4. カスタム セキュリティ属性を割り当てるユーザーを検索して選択します。

  5. [管理] セクションで、[カスタム セキュリティ属性] を選択してください。

  6. [割り当ての追加] を選択します。

  7. [Attribute set](属性セット) で、一覧から属性セットを選択します。

  8. [属性名] で、一覧からカスタム セキュリティ属性を選択します。

  9. 選択したカスタム セキュリティ属性のプロパティに応じて、1 つの値を入力したり、定義済みの一覧から値を選択したり、複数の値を追加したりできます。

    • 自由形式の単一値カスタム セキュリティ属性の場合は、[Assigned values](割り当てられた値) ボックスに値を入力します。
    • 定義済みのカスタム セキュリティ属性値については、[Assigned values](割り当てられた値) リストから値を選択します。
    • 複数値のカスタム セキュリティ属性の場合は、[Add values](値の追加) を選択して [Attribute values](属性値) ペインを開き、値を追加します。 値の入力が完了したら、[OK] を選択します。

    Screenshot showing assigning a custom security attribute to a user.

  10. 完了したら、[保存] を選択して、カスタム セキュリティ属性をユーザーに割り当てます。

ユーザーのカスタム セキュリティ属性の割り当て値を更新する

  1. Microsoft Entra 管理センター属性割り当て管理者としてサインインしてください。

  2. [ID]>[ユーザー]>[すべてのユーザー] の順に移動します。

  3. 更新するカスタム セキュリティ属性の割り当て値を持つユーザーを検索して選択します。

  4. [管理] セクションで、[カスタム セキュリティ属性] を選択してください。

  5. 更新するカスタム セキュリティ属性の割り当て値を見つけます。

    カスタム セキュリティ属性をユーザーに割り当てた後は、カスタム セキュリティ属性の値のみを変更できます。 属性セットや属性名など、カスタム セキュリティ属性のその他のプロパティを変更することはできません。

  6. 選択したカスタム セキュリティ属性のプロパティに応じて、1つの値を更新したり、定義済みの一覧から値を選択したり、複数の値を更新したりできます。

  7. 終わったら、 [保存] を選択します。

カスタム セキュリティ属性割り当てに基づいてユーザーをフィルター処理する

[すべてのユーザー] ページで、ユーザーに割り当てられているカスタム セキュリティ属性のリストをフィルター処理できます。

  1. Microsoft Entra 管理センター属性割り当て閲覧者としてサインインしてください。

  2. [ID]>[ユーザー]>[すべてのユーザー] の順に移動します。

  3. [フィルターを追加する] を選択して、[フィルターを追加する] ウィンドウを開きます。

  4. [Custom security attributes](カスタム セキュリティ属性) を選択します。

  5. 属性セットと属性名を選択します。

  6. [演算子]には、等号 (==)、不等号 (!=)、または [次の値で始まる] が選択できます。

  7. [値] には、値を入力または選択します。

    Screenshot showing a custom security attribute filter for users.

  8. [適用] を選択して、フィルターを適用します。

ユーザーからカスタム セキュリティ属性の割り当てを削除する

  1. Microsoft Entra 管理センター属性割り当て管理者としてサインインしてください。

  2. [ID]>[ユーザー]>[すべてのユーザー] の順に移動します。

  3. 削除するカスタム セキュリティ属性の割り当て値を持つユーザーを検索して選択します。

  4. [管理] セクションで、[カスタム セキュリティ属性] を選択してください。

  5. 削除するすべてのカスタム セキュリティ属性の割り当ての横にチェックマークを追加します。

  6. [割り当ての削除]を選択します。

PowerShell または Microsoft Graph API

Microsoft Entra 組織内のユーザーのカスタム セキュリティ属性の割り当てを管理するには、PowerShell または Microsoft Graph API を使用できます。 割り当ての管理には、次の例を使用できます。

文字列値を持つカスタム セキュリティ属性をユーザーに割り当てる

次の例では、文字列値を持つカスタム セキュリティ属性をユーザーに割り当てます。

  • 属性セット: Engineering
  • 属性: ProjectDate
  • 属性のデータ型: 文字列
  • 属性値: "2024-11-15"

Update-MgUser

$customSecurityAttributes = @{
    "Engineering" = @{
        "@odata.type" = "#Microsoft.DirectoryServices.CustomSecurityAttributeValue"
        "ProjectDate" = "2024-11-15"
    }
}
Update-MgUser -UserId $userId -CustomSecurityAttributes $customSecurityAttributes

複数の文字列値を持つカスタム セキュリティ属性をユーザーに割り当てる

次の例では、複数文字列値を持つカスタム セキュリティ属性をユーザーに割り当てます。

  • 属性セット: Engineering
  • 属性: Project
  • 属性のデータ型: 文字列のコレクション
  • 属性値: ["Baker","Cascade"]

Update-MgUser

$customSecurityAttributes = @{
    "Engineering" = @{
        "@odata.type" = "#Microsoft.DirectoryServices.CustomSecurityAttributeValue"
        "Project@odata.type" = "#Collection(String)"
        "Project" = @("Baker","Cascade")
    }
}
Update-MgUser -UserId $userId -CustomSecurityAttributes $customSecurityAttributes

整数値を持つカスタム セキュリティ属性をユーザーに割り当てる

次の例では、整数値を持つカスタム セキュリティ属性をユーザーに割り当てます。

  • 属性セット: Engineering
  • 属性: NumVendors
  • 属性のデータ型: 整数
  • 属性値: 4

Update-MgUser

$customSecurityAttributes = @{
    "Engineering" = @{
        "@odata.type" = "#Microsoft.DirectoryServices.CustomSecurityAttributeValue"
        "NumVendors@odata.type" = "#Int32"
        "NumVendors" = 4
    }
}
Update-MgUser -UserId $userId -CustomSecurityAttributes $customSecurityAttributes

複数の整数値を持つカスタム セキュリティ属性をユーザーに割り当てる

次の例では、複数整数値を持つカスタム セキュリティ属性をユーザーに割り当てます。

  • 属性セット: Engineering
  • 属性: CostCenter
  • 属性のデータ型: 整数のコレクション
  • 属性値: [1001,1003]

Update-MgUser

$customSecurityAttributes = @{
    "Engineering" = @{
        "@odata.type" = "#Microsoft.DirectoryServices.CustomSecurityAttributeValue"
        "CostCenter@odata.type" = "#Collection(Int32)"
        "CostCenter" = @(1001,1003)
    }
}
Update-MgUser -UserId $userId -CustomSecurityAttributes $customSecurityAttributes

ブール値を持つカスタム セキュリティ属性をユーザーに割り当てる

次の例では、ブール値を持つカスタム セキュリティ属性をユーザーに割り当てます。

  • 属性セット: Engineering
  • 属性: Certification
  • 属性のデータ型: ブール値
  • 属性値: true

Update-MgUser

$customSecurityAttributes = @{
    "Engineering" = @{
        "@odata.type" = "#Microsoft.DirectoryServices.CustomSecurityAttributeValue"
        "Certification" = $true
    }
}
Update-MgUser -UserId $userId -CustomSecurityAttributes $customSecurityAttributes

ユーザーの整数値を持つカスタム セキュリティ属性割り当てを更新する

次の例では、ユーザーの整数値を持つカスタム セキュリティ属性割り当てを更新します。

  • 属性セット: Engineering
  • 属性: NumVendors
  • 属性のデータ型: 整数
  • 属性値: 8

Update-MgUser

$customSecurityAttributes = @{
    "Engineering" = @{
        "@odata.type" = "#Microsoft.DirectoryServices.CustomSecurityAttributeValue"
        "NumVendors@odata.type" = "#Int32"
        "NumVendors" = 8
    }
}
Update-MgUser -UserId $userId -CustomSecurityAttributes $customSecurityAttributes

ユーザーのブール値を持つカスタム セキュリティ属性割り当てを更新する

次の例では、ユーザーのブール値を持つカスタム セキュリティ属性割り当てを更新します。

  • 属性セット: Engineering
  • 属性: Certification
  • 属性のデータ型: ブール値
  • 属性値: false

Update-MgUser

$customSecurityAttributes = @{
    "Engineering" = @{
        "@odata.type" = "#Microsoft.DirectoryServices.CustomSecurityAttributeValue"
        "Certification" = $false
    }
}
Update-MgUser -UserId $userId -CustomSecurityAttributes $customSecurityAttributes

ユーザーの複数文字列値を持つカスタム セキュリティ属性割り当てを更新する

次の例では、ユーザーの複数文字列値を持つカスタム セキュリティ属性割り当てを更新します。

  • 属性セット: Engineering
  • 属性: Project
  • 属性のデータ型: 文字列のコレクション
  • 属性値: ("Alpine","Baker")

Update-MgUser

$customSecurityAttributes = @{
    "Engineering" = @{
        "@odata.type" = "#Microsoft.DirectoryServices.CustomSecurityAttributeValue"
        "Project@odata.type" = "#Collection(String)"
        "Project" = @("Alpine","Baker")
    }
}
Update-MgUser -UserId $userId -CustomSecurityAttributes $customSecurityAttributes

ユーザーからカスタム セキュリティ属性の割り当てを取得する

次の例では、ユーザーのカスタム セキュリティ属性の割り当てを取得します。

Get-MgUser

$userAttributes = Get-MgUser -UserId $userId -Property "customSecurityAttributes"
$userAttributes.CustomSecurityAttributes.AdditionalProperties | Format-List
$userAttributes.CustomSecurityAttributes.AdditionalProperties.Engineering
$userAttributes.CustomSecurityAttributes.AdditionalProperties.Marketing
Key   : Engineering
Value : {[@odata.type, #microsoft.graph.customSecurityAttributeValue], [Project@odata.type, #Collection(String)], [Project, System.Object[]],
        [ProjectDate, 2024-11-15]…}

Key   : Marketing
Value : {[@odata.type, #microsoft.graph.customSecurityAttributeValue], [EmployeeId, GS45897]}


Key                   Value
---                   -----
@odata.type           #microsoft.graph.customSecurityAttributeValue
Project@odata.type    #Collection(String)
Project               {Baker, Alpine}
ProjectDate           2024-11-15
NumVendors            8
CostCenter@odata.type #Collection(Int32)
CostCenter            {1001, 1003}
Certification         False


Key         Value
---         -----
@odata.type #microsoft.graph.customSecurityAttributeValue
EmployeeId  KX45897

ユーザーにカスタム セキュリティ属性が割り当てられていない場合、または呼び出し元のプリンシパルにアクセス権がない場合、応答は空になります。

値と等しいカスタム セキュリティ属性の割り当てを持つすべてのユーザーを一覧表示する

次の例では、値と等しいカスタム セキュリティ属性の割り当てを持つすべてのユーザーを一覧表示します。 値が Canada と等しい AppCountry という名前のカスタム セキュリティ属性を持つユーザーを取得します。 フィルター値は大文字と小文字が区別されます。 要求またはヘッダーに ConsistencyLevel=eventual を追加する必要があります。 要求が正しくルーティングされるようにするには、 $count=true も含める必要があります。

  • 属性セット: Marketing
  • 属性: AppCountry
  • フィルター: AppCountry eq 'Canada'

Get-MgUser

$userAttributes = Get-MgUser -CountVariable CountVar -Property "id,displayName,customSecurityAttributes" -Filter "customSecurityAttributes/Marketing/AppCountry eq 'Canada'" -ConsistencyLevel eventual
$userAttributes | select Id,DisplayName,CustomSecurityAttributes
$userAttributes.CustomSecurityAttributes.AdditionalProperties | Format-List
Id                                   DisplayName CustomSecurityAttributes
--                                   ----------- ------------------------
00aa00aa-bb11-cc22-dd33-44ee44ee44ee Jiya        Microsoft.Graph.PowerShell.Models.MicrosoftGraphCustomSecurityAttributeValue
11bb11bb-cc22-dd33-ee44-55ff55ff55ff Jana        Microsoft.Graph.PowerShell.Models.MicrosoftGraphCustomSecurityAttributeValue

Key   : Engineering
Value : {[@odata.type, #microsoft.graph.customSecurityAttributeValue], [Datacenter@odata.type, #Collection(String)], [Datacenter, System.Object[]]}

Key   : Marketing
Value : {[@odata.type, #microsoft.graph.customSecurityAttributeValue], [AppCountry@odata.type, #Collection(String)], [AppCountry, System.Object[]],
        [EmployeeId, KX19476]}

Key   : Marketing
Value : {[@odata.type, #microsoft.graph.customSecurityAttributeValue], [AppCountry@odata.type, #Collection(String)], [AppCountry, System.Object[]],
        [EmployeeId, GS46982]}

値で始まるカスタム セキュリティ属性の割り当てを持つすべてのユーザーを一覧表示する

次の例では、値で始まるカスタム セキュリティ属性の割り当てを持つすべてのユーザーを一覧表示します。 値が GS で始まる EmployeeId という名前のカスタム セキュリティ属性を持つユーザーを取得します。 フィルター値は大文字と小文字が区別されます。 要求またはヘッダーに ConsistencyLevel=eventual を追加する必要があります。 要求が正しくルーティングされるようにするには、 $count=true も含める必要があります。

  • 属性セット: Marketing
  • 属性: EmployeeId
  • フィルター: EmployeeId startsWith 'GS'

Get-MgUser

$userAttributes = Get-MgUser -CountVariable CountVar -Property "id,displayName,customSecurityAttributes" -Filter "startsWith(customSecurityAttributes/Marketing/EmployeeId,'GS')" -ConsistencyLevel eventual
$userAttributes | select Id,DisplayName,CustomSecurityAttributes
$userAttributes.CustomSecurityAttributes.AdditionalProperties | Format-List
Id                                   DisplayName CustomSecurityAttributes
--                                   ----------- ------------------------
22cc22cc-dd33-ee44-ff55-66aa66aa66aa Chandra     Microsoft.Graph.PowerShell.Models.MicrosoftGraphCustomSecurityAttributeValue
11bb11bb-cc22-dd33-ee44-55ff55ff55ff Jana        Microsoft.Graph.PowerShell.Models.MicrosoftGraphCustomSecurityAttributeValue
33dd33dd-ee44-ff55-aa66-77bb77bb77bb Joe         Microsoft.Graph.PowerShell.Models.MicrosoftGraphCustomSecurityAttributeValue

Key   : Marketing
Value : {[@odata.type, #microsoft.graph.customSecurityAttributeValue], [EmployeeId, GS36348]}

Key   : Marketing
Value : {[@odata.type, #microsoft.graph.customSecurityAttributeValue], [AppCountry@odata.type, #Collection(String)], [AppCountry, System.Object[]],
        [EmployeeId, GS46982]}

Key   : Engineering
Value : {[@odata.type, #microsoft.graph.customSecurityAttributeValue], [Project@odata.type, #Collection(String)], [Project, System.Object[]],
        [ProjectDate, 2024-11-15]…}

Key   : Marketing
Value : {[@odata.type, #microsoft.graph.customSecurityAttributeValue], [EmployeeId, GS45897]}

値と等しくないカスタム セキュリティ属性の割り当てを持つすべてのユーザーを一覧表示する

次の例では、値と等しくないカスタム セキュリティ属性の割り当てを持つすべてのユーザーを一覧表示します。 値が Canada と等しくない AppCountry という名前のカスタム セキュリティ属性を持つユーザーを取得します。 フィルター値は大文字と小文字が区別されます。 要求またはヘッダーに ConsistencyLevel=eventual を追加する必要があります。 要求が正しくルーティングされるようにするには、 $count=true も含める必要があります。

  • 属性セット: Marketing
  • 属性: AppCountry
  • フィルター: AppCountry ne 'Canada'

Get-MgUser

$userAttributes = Get-MgUser -CountVariable CountVar -Property "id,displayName,customSecurityAttributes" -Filter "customSecurityAttributes/Marketing/AppCountry ne 'Canada'" -ConsistencyLevel eventual
$userAttributes | select Id,DisplayName,CustomSecurityAttributes
Id                                   DisplayName              CustomSecurityAttributes
--                                   -----------              ------------------------
22cc22cc-dd33-ee44-ff55-66aa66aa66aa Chandra                  Microsoft.Graph.PowerShell.Models.MicrosoftGraphCustomSecurityAttributeValue
44ee44ee-ff55-aa66-bb77-88cc88cc88cc Isabella                 Microsoft.Graph.PowerShell.Models.MicrosoftGraphCustomSecurityAttributeValue
00aa00aa-bb11-cc22-dd33-44ee44ee44ee Alain                    Microsoft.Graph.PowerShell.Models.MicrosoftGraphCustomSecurityAttributeValue
33dd33dd-ee44-ff55-aa66-77bb77bb77bb Joe                      Microsoft.Graph.PowerShell.Models.MicrosoftGraphCustomSecurityAttributeValue
00aa00aa-bb11-cc22-dd33-44ee44ee44ee Dara                     Microsoft.Graph.PowerShell.Models.MicrosoftGraphCustomSecurityAttributeValue

ユーザーから単一値のカスタム セキュリティ属性の割り当てを削除する

次の例では、値を null に設定することによって、ユーザーから単一値のカスタム セキュリティ属性の割り当てを削除します。

  • 属性セット: Engineering
  • 属性: ProjectDate
  • 属性値: null

Invoke-MgGraphRequest

$params = @{
    "customSecurityAttributes" = @{
        "Engineering" = @{
            "@odata.type" = "#Microsoft.DirectoryServices.CustomSecurityAttributeValue"
            "ProjectDate" = $null
        }
    }
}
Invoke-MgGraphRequest -Method PATCH -Uri "https://graph.microsoft.com/v1.0/users/$userId" -Body $params

ユーザーから複数値のカスタム セキュリティ属性の割り当てを削除する

次の例では、値を空のコレクションに設定することによって、ユーザーから複数値のカスタム セキュリティ属性の割り当てを削除します。

  • 属性セット: Engineering
  • 属性: Project
  • 属性値: []

Update-MgUser

$customSecurityAttributes = @{
    "Engineering" = @{
        "@odata.type" = "#Microsoft.DirectoryServices.CustomSecurityAttributeValue"
        "Project" = @()
    }
}
Update-MgUser -UserId $userId -CustomSecurityAttributes $customSecurityAttributes

よく寄せられる質問

ユーザーのカスタム セキュリティ属性の割り当てはどこでサポートされていますか。

ユーザーのカスタム セキュリティ属性の割り当ては、Microsoft Entra 管理センター、PowerShell、Microsoft Graph API でサポートされています。 カスタム セキュリティ属性の割り当ては、マイ アプリおよび Microsoft 365 管理センターではサポートされていません。

ユーザーに割り当てられているカスタム セキュリティ属性は誰が表示できますか。

テナント内の任意のユーザーに割り当てられたカスタム セキュリティ属性を表示できるのは、テナント スコープで属性割り当て管理者ロールまたは属性割り当て閲覧者ロールが割り当てられているユーザーだけです。 ユーザーは、自分のプロファイルまたは他のユーザーに割り当てられたカスタム セキュリティ属性を表示できません。 テナントに設定されているゲストのアクセス許可に関係なく、ゲストはカスタム セキュリティ属性を表示できません。

カスタム セキュリティ属性の割り当てを追加するのに、アプリを作成する必要がありますか。

いいえ。カスタム セキュリティ属性は、アプリケーションを必要とせずにユーザー オブジェクトに割り当てることができます。

カスタム セキュリティ属性の割り当てを保存しようとするとエラーが発生し続けるのはなぜですか。

カスタム セキュリティ属性をユーザーに割り当てるアクセス許可がありません。 属性割り当て管理者ロールが割り当てられている必要があります。

ゲストにカスタム セキュリティ属性を割り当てることはできますか。

はい。カスタム セキュリティ属性は、テナント内のメンバーまたはゲストに割り当てることができます。

ディレクトリ同期済みのユーザーにカスタム セキュリティ属性を割り当てることはできますか。

はい。オンプレミスの Active Directory のディレクトリ同期済みのユーザーにカスタム セキュリティ属性を割り当てることができます。

動的メンバーシップ ルールでは、カスタム セキュリティ属性の割り当てを使用することができますか。

いいえ。動的メンバーシップ ルールの構成では、ユーザーに割り当てられたカスタム セキュリティ属性はサポートされていません。

カスタム セキュリティ属性は B2C テナントのカスタム属性と同じですか。

いいえ。B2C テナントではカスタム セキュリティ属性はサポートされていません。また、カスタム セキュリティ属性はB2C 機能には関連付けされていません。

次のステップ