分享方式:


在 Entra ID Microsoft 中新增或停用自訂安全性屬性定義

Microsoft Entra ID 中的 自訂安全性屬性 是您可以定義並指派給 Microsoft Entra 物件的商務特定屬性 (索引鍵/值組)。 本文說明如何新增、編輯或停用自訂安全性屬性定義。

必要條件

若要新增或停用自訂安全性屬性定義,您需有:

重要

依預設,全域管理員和其他系統管理員角色無權讀取、定義或指派自訂安全性屬性。

新增屬性集

提示

根據您開始使用的入口網站,本文中的步驟可能略有不同。

屬性集為相關屬性的集合。 所有自訂安全性屬性都必須屬於屬性集。 屬性集無法重新命名或刪除。

  1. 屬性定義系統管理員 身分登入 Microsoft Entra 系統管理中心

  2. 瀏覽至 Protection>自訂安全性屬性

  3. 按一下 [新增屬性集] 以新增屬性集。

    如果 [新增屬性集] 已停用,請確認您已獲派「屬性定義管理員」角色。 如需詳細資訊,請參閱對自訂安全性屬性進行疑難排解 (機器翻譯)

  4. 輸入名稱、說明和屬性數目上限。

    屬性集名稱可有 32 個字元,不含空格或特殊字元。 指定名稱後,就無法重新命名。 如需詳細資訊,請參閱限制和條件約束 (機器翻譯)

    Microsoft Entra 系統管理中心的 [新增屬性集] 窗格螢幕擷取畫面。

  5. 完成後,按一下 [新增]

    新屬性集會出現在屬性集清單中。

新增自訂安全性屬性定義

  1. 屬性定義系統管理員 身分登入 Microsoft Entra 系統管理中心

  2. 瀏覽至 Protection>自訂安全性屬性

  3. 在 [自訂安全性屬性] 頁面上,尋找現有屬性集,或按一下 [新增屬性集],以新增屬性集。

    所有自訂安全性屬性定義都必須屬於屬性集。

  4. 按一下以開啟選取的屬性集。

  5. 按一下 [新增屬性集],將自訂安全性屬性新增至屬性集。

    Microsoft Entra 系統管理中心的 [新增屬性] 窗格螢幕擷取畫面。

  6. 在 [屬性名稱] 方塊中,輸入自訂安全性屬性名稱。

    自訂安全性屬性名稱可有 32 個字元,不含空格或特殊字元。 指定名稱後,就無法重新命名。 如需詳細資訊,請參閱限制和條件約束 (機器翻譯)

  7. 在 [說明] 方塊中,輸入選填說明。

    說明長度可為 128 個字元。 如有必要,您可以稍後變更說明。

  8. 從 [資料類型] 清單中,選取自訂安全性屬性的資料類型。

    資料類型 描述
    布林值 可能為 true、True、false 或 False 的布林值。
    整數 32 位元整數。
    String 長度可為 X 個字元的字串。
  9. 針對 [允許指派多個值],請選取 [是] 或 [否]

    選取 [是],允許將多個值指派給此自訂安全性屬性。 選取 [否],只允許將單一值指派給此自訂安全性屬性。

  10. 針對 [只允許指派預先定義的值],請選取 [是] 或 [否]

    選取 [是],要求從預先定義的值清單中指派此自訂安全性屬性。 選取 [否],允許此自訂安全性屬性獲派使用者定義值或可能預先定義的值。

  11. 如果 [只允許指派預先定義的值] 為 [是],請按一下 [新增值],新增預先定義的值。

    使用中的值可供指派給物件。 非使用中的值已定義,但尚無法指派。

    Microsoft Entra 系統管理中心中的 [新增屬性] 窗格,其中有 [新增預先定義值] 窗格的螢幕擷取畫面。

  12. 完成時,按一下 [儲存]。

    新自訂安全性屬性會出現在自訂安全性屬性清單中。

  13. 如果您想加入預先定義的值,請依照下一節中的步驟操作。

編輯自訂安全性屬性定義

新增自訂安全性屬性定義之後,您就可在稍後編輯部分屬性。 部分屬性不可變,且無法變更。

  1. 屬性定義系統管理員 身分登入 Microsoft Entra 系統管理中心

  2. 瀏覽至 Protection>自訂安全性屬性

  3. 按一下包含您要編輯之自訂安全性屬性的屬性集。

  4. 在自訂安全性屬性清單中,按一下您要編輯之自訂安全性屬性的省略符號,然後選擇 [編輯屬性]

  5. 編輯已啟用的屬性。

  6. 如果 [只允許指派預先定義的值] 為 [是],請按一下 [新增值],新增預先定義的值。 按一下現有預先定義的值,變更 [使用中?] 設定。

    Microsoft Entra 系統管理中心中 [新增預先定義值] 窗格的螢幕擷取畫面。

停用自訂安全性屬性定義

新增自訂安全性屬性定義後,您就無法刪除。 不過,您可以停用自訂安全性屬性定義。

  1. 屬性定義系統管理員 身分登入 Microsoft Entra 系統管理中心

  2. 瀏覽至 Protection>自訂安全性屬性

  3. 按一下包含您要停用之自訂安全性屬性的屬性集。

  4. 在自訂安全性屬性清單中,在您想停用的自訂安全性屬性旁新增勾選記號。

  5. 按一下 [停用屬性]

  6. 在出現的 [停用屬性] 對話方塊中,按一下 [是]

    自訂安全性屬性已停用,並移至 [停用的屬性] 清單。

PowerShell 或 Microsoft Graph API

您也可以使用 PowerShell 或 Microsoft Graph API 來管理 Microsoft Entra 組織中的自訂安全性屬性定義。 以下範例可以管理屬性集和自訂安全性屬性定義。

取得所有屬性集

下列範例會取得所有屬性集。

Get-MgDirectoryAttributeSet

Get-MgDirectoryAttributeSet | Format-List
Description          : Attributes for engineering team
Id                   : Engineering
MaxAttributesPerSet  : 25
AdditionalProperties : {}

Description          : Attributes for marketing team
Id                   : Marketing
MaxAttributesPerSet  : 25
AdditionalProperties : {}

取得常用屬性集

下列範例會取得頂端屬性集。

Get-MgDirectoryAttributeSet

Get-MgDirectoryAttributeSet -Top 10

取得依照順序排列的屬性集

下列範例會依序取得屬性集。

Get-MgDirectoryAttributeSet

Get-MgDirectoryAttributeSet -Sort "Id"

取得屬性集

下列範例會取得屬性集。

  • 屬性集:Engineering

Get-MgDirectoryAttributeSet

Get-MgDirectoryAttributeSet -AttributeSetId "Engineering" | Format-List
Description          : Attributes for engineering team
Id                   : Engineering
MaxAttributesPerSet  : 25
AdditionalProperties : {[@odata.context, https://graph.microsoft.com/v1.0/$metadata#directory/attributeSets/$entity]}

新增屬性集

下列範例會新增屬性集。

  • 屬性集:Engineering

New-MgDirectoryAttributeSet

$params = @{
    Id = "Engineering"
    Description = "Attributes for engineering team"
    MaxAttributesPerSet = 25
}
New-MgDirectoryAttributeSet -BodyParameter $params
Id          Description                     MaxAttributesPerSet
--          -----------                     -------------------
Engineering Attributes for engineering team 25

更新屬性集

下列範例會更新屬性集。

  • 屬性集:Engineering

Update-MgDirectoryAttributeSet

$params = @{
    description = "Attributes for engineering team"
    maxAttributesPerSet = 20
}
Update-MgDirectoryAttributeSet -AttributeSetId "Engineering" -BodyParameter $params

取得所有自訂安全性屬性定義

下列範例會取得所有自訂安全性屬性定義。

Get-MgDirectoryCustomSecurityAttributeDefinition

Get-MgDirectoryCustomSecurityAttributeDefinition | Format-List
AllowedValues           :
AttributeSet            : Engineering
Description             : Target completion date
Id                      : Engineering_ProjectDate
IsCollection            : False
IsSearchable            : True
Name                    : ProjectDate
Status                  : Available
Type                    : String
UsePreDefinedValuesOnly : False
AdditionalProperties    : {}

AllowedValues           :
AttributeSet            : Engineering
Description             : Active projects for user
Id                      : Engineering_Project
IsCollection            : True
IsSearchable            : True
Name                    : Project
Status                  : Available
Type                    : String
UsePreDefinedValuesOnly : True
AdditionalProperties    : {}

AllowedValues           :
AttributeSet            : Marketing
Description             : Country where is application is used
Id                      : Marketing_AppCountry
IsCollection            : True
IsSearchable            : True
Name                    : AppCountry
Status                  : Available
Type                    : String
UsePreDefinedValuesOnly : True
AdditionalProperties    : {}

篩選自訂安全性屬性定義

下列範例會篩選自訂安全性屬性定義。

  • 篩選條件:Attribute name eq 'Project' and status eq 'Available'

Get-MgDirectoryCustomSecurityAttributeDefinition

Get-MgDirectoryCustomSecurityAttributeDefinition -Filter "name eq 'Project' and status eq 'Available'" | Format-List
AllowedValues           :
AttributeSet            : Engineering
Description             : Active projects for user
Id                      : Engineering_Project
IsCollection            : True
IsSearchable            : True
Name                    : Project
Status                  : Available
Type                    : String
UsePreDefinedValuesOnly : True
AdditionalProperties    : {}
  • 篩選條件:Attribute set eq 'Engineering' and status eq 'Available' and data type eq 'String'

Get-MgDirectoryCustomSecurityAttributeDefinition

Get-MgDirectoryCustomSecurityAttributeDefinition -Filter "attributeSet eq 'Engineering' and status eq 'Available' and type eq 'String'" | Format-List
AllowedValues           :
AttributeSet            : Engineering
Description             : Target completion date
Id                      : Engineering_ProjectDate
IsCollection            : False
IsSearchable            : True
Name                    : ProjectDate
Status                  : Available
Type                    : String
UsePreDefinedValuesOnly : False
AdditionalProperties    : {}

AllowedValues           :
AttributeSet            : Engineering
Description             : Active projects for user
Id                      : Engineering_Project
IsCollection            : True
IsSearchable            : True
Name                    : Project
Status                  : Available
Type                    : String
UsePreDefinedValuesOnly : True
AdditionalProperties    : {}

取得自訂安全性屬性定義

下列範例會取得自訂安全性屬性定義。

  • 屬性集:Engineering
  • 屬性:ProjectDate

Get-MgDirectoryCustomSecurityAttributeDefinition

Get-MgDirectoryCustomSecurityAttributeDefinition -CustomSecurityAttributeDefinitionId "Engineering_ProjectDate" | Format-List
AllowedValues           :
AttributeSet            : Engineering
Description             : Target completion date
Id                      : Engineering_ProjectDate
IsCollection            : False
IsSearchable            : True
Name                    : ProjectDate
Status                  : Available
Type                    : String
UsePreDefinedValuesOnly : False
AdditionalProperties    : {[@odata.context, https://graph.microsoft.com/v1.0/$metadata#directory/customSecurityAttributeDefinitions/$entity]}

新增自訂安全性屬性定義

下列範例會新增自訂安全性屬性定義。

  • 屬性集:Engineering
  • 屬性:ProjectDate
  • 屬性資料類型:字串

New-MgDirectoryCustomSecurityAttributeDefinition

$params = @{
    attributeSet = "Engineering"
    description = "Target completion date"
    isCollection = $false
    isSearchable = $true
    name = "ProjectDate"
    status = "Available"
    type = "String"
    usePreDefinedValuesOnly = $false
}
New-MgDirectoryCustomSecurityAttributeDefinition -BodyParameter $params | Format-List
AllowedValues           :
AttributeSet            : Engineering
Description             : Target completion date
Id                      : Engineering_ProjectDate
IsCollection            : False
IsSearchable            : True
Name                    : ProjectDate
Status                  : Available
Type                    : String
UsePreDefinedValuesOnly : False
AdditionalProperties    : {[@odata.context, https://graph.microsoft.com/v1.0/$metadata#directory/customSecurityAttributeDefinitions/$entity]}

新增支援多個預先定義值的自訂安全性屬性定義

下列範例會新增支援多個預先定義值的自訂安全性屬性定義。

  • 屬性集:Engineering
  • 屬性:Project
  • 屬性資料類型:字串集合

New-MgDirectoryCustomSecurityAttributeDefinition

$params = @{
    attributeSet = "Engineering"
    description = "Active projects for user"
    isCollection = $true
    isSearchable = $true
    name = "Project"
    status = "Available"
    type = "String"
    usePreDefinedValuesOnly = $true
}
New-MgDirectoryCustomSecurityAttributeDefinition -BodyParameter $params | Format-List
AllowedValues           :
AttributeSet            : Engineering
Description             : Active projects for user
Id                      : Engineering_Project
IsCollection            : True
IsSearchable            : True
Name                    : Project
Status                  : Available
Type                    : String
UsePreDefinedValuesOnly : True
AdditionalProperties    : {[@odata.context, https://graph.microsoft.com/v1.0/$metadata#directory/customSecurityAttributeDefinitions/$entity]}

新增具有預先定義值清單的自訂安全性屬性定義

下列範例會新增具有預先定義值清單的自訂安全性屬性定義。

  • 屬性集:Engineering
  • 屬性:Project
  • 屬性資料類型:字串集合
  • 預先定義的值:AlpineBakerCascade

New-MgDirectoryCustomSecurityAttributeDefinition

$params = @{
    attributeSet = "Engineering"
    description = "Active projects for user"
    isCollection = $true
    isSearchable = $true
    name = "Project"
    status = "Available"
    type = "String"
    usePreDefinedValuesOnly = $true
    allowedValues = @(
        @{
            id = "Alpine"
            isActive = $true
        }
        @{
            id = "Baker"
            isActive = $true
        }
        @{
            id = "Cascade"
            isActive = $true
        }
    )
}
New-MgDirectoryCustomSecurityAttributeDefinition -BodyParameter $params | Format-List
AllowedValues           :
AttributeSet            : Engineering
Description             : Active projects for user
Id                      : Engineering_Project
IsCollection            : True
IsSearchable            : True
Name                    : Project
Status                  : Available
Type                    : String
UsePreDefinedValuesOnly : True
AdditionalProperties    : {[@odata.context, https://graph.microsoft.com/v1.0/$metadata#directory/customSecurityAttributeDefinitions/$entity]}

更新自訂安全性屬性定義

下列範例會更新自訂安全性屬性定義。

  • 屬性集:Engineering
  • 屬性:ProjectDate

Update-MgDirectoryCustomSecurityAttributeDefinition

$params = @{
    description = "Target completion date (YYYY/MM/DD)"
}
Update-MgDirectoryCustomSecurityAttributeDefinition -CustomSecurityAttributeDefinitionId "Engineering_ProjectDate" -BodyParameter $params

更新自訂安全性屬性定義的預先定義值

下列範例會更新自訂安全性屬性定義的預先定義值。

  • 屬性集:Engineering
  • 屬性:Project
  • 屬性資料類型:字串集合
  • 更新預先定義的值:Baker
  • 新預先定義的值:Skagit

Invoke-MgGraphRequest

注意

針對此要求,您必須新增 [OData-Version] 標頭,並指派值 4.01

$params = @{
    "allowedValues@delta" = @(
        @{
            id = "Baker"
            isActive = $false
        }
        @{
            id = "Skagit"
            isActive = $true
        }
    )
}
$header = @{
    "OData-Version" = 4.01
}
Invoke-MgGraphRequest -Method PATCH -Uri "https://graph.microsoft.com/v1.0/directory/customSecurityAttributeDefinitions/Engineering_Project5" -Headers $header -Body $params

停用自訂安全性屬性定義

下列範例會停用自訂安全性屬性定義。

  • 屬性集:Engineering
  • 屬性:Project

Update-MgDirectoryCustomSecurityAttributeDefinition

$params = @{
    status = "Deprecated"
}
Update-MgDirectoryCustomSecurityAttributeDefinition -CustomSecurityAttributeDefinitionId "Engineering_ProjectDate" -BodyParameter $params

取得所有預先定義的值

下列範例會取得自訂安全性屬性定義的所有預先定義值。

  • 屬性集:Engineering
  • 屬性:Project

Get-MgDirectoryCustomSecurityAttributeDefinitionAllowedValue

Get-MgDirectoryCustomSecurityAttributeDefinitionAllowedValue -CustomSecurityAttributeDefinitionId "Engineering_Project" | Format-List
Id                   : Skagit
IsActive             : True
AdditionalProperties : {}

Id                   : Baker
IsActive             : False
AdditionalProperties : {}

Id                   : Cascade
IsActive             : True
AdditionalProperties : {}

Id                   : Alpine
IsActive             : True
AdditionalProperties : {}

取得預先定義的值

下列範例會取得自訂安全性屬性定義的預先定義值。

  • 屬性集:Engineering
  • 屬性:Project
  • 預先定義的值:Alpine

Get-MgDirectoryCustomSecurityAttributeDefinitionAllowedValue

Get-MgDirectoryCustomSecurityAttributeDefinitionAllowedValue -CustomSecurityAttributeDefinitionId "Engineering_Project" -AllowedValueId "Alpine" | Format-List
Id                   : Alpine
IsActive             : True
AdditionalProperties : {[@odata.context, https://graph.microsoft.com/v1.0/$metadata#directory/customSecurityAttributeDefinitions('Engineering_Project')/al
                       lowedValues/$entity]}

新增預先定義的值

下列範例會新增自訂安全性屬性定義的預先定義值。

您可以為已將 usePreDefinedValuesOnly 設定為 true 的自訂安全性屬性,新增預先定義的值。

  • 屬性集:Engineering
  • 屬性:Project
  • 預先定義的值:Alpine

New-MgDirectoryCustomSecurityAttributeDefinitionAllowedValue

$params = @{
    id = "Alpine"
    isActive = $true
}
New-MgDirectoryCustomSecurityAttributeDefinitionAllowedValue -CustomSecurityAttributeDefinitionId "Engineering_Project" -BodyParameter $params | Format-List
Id                   : Alpine
IsActive             : True
AdditionalProperties : {[@odata.context, https://graph.microsoft.com/v1.0/$metadata#directory/customSecurityAttributeDefinitions('Engineering_Project')/al
                       lowedValues/$entity]}

停用預先定義的值

下列範例會停用自訂安全性屬性定義的預先定義值。

  • 屬性集:Engineering
  • 屬性:Project
  • 預先定義的值:Alpine

Update-MgDirectoryCustomSecurityAttributeDefinitionAllowedValue

$params = @{
    isActive = $false
}
Update-MgDirectoryCustomSecurityAttributeDefinitionAllowedValue -CustomSecurityAttributeDefinitionId "Engineering_Project" -AllowedValueId "Alpine" -BodyParameter $params

常見問題集

是否可刪除自訂安全性屬性定義?

否,您無法刪除自訂安全性屬性定義。 您只能停用自訂安全性屬性定義。 停用自訂安全性屬性後,就無法再套用至 Microsoft Entra 物件。 系統不會自動移除所停用自訂安全性屬性定義的自訂安全性屬性指派。 停用的自訂安全性屬性數目沒有任何限制。 每個租用戶可有 500 個使用中的自訂安全性屬性定義,而每個自訂安全性屬性定義可有 100 個預先定義的值。

下一步