管理應用程式的自訂安全性屬性

Microsoft Entra ID 中的自訂安全性屬性 (部分機器翻譯) 是您可以定義並指派給 Microsoft Entra 物件的商務特定屬性 (索引鍵/值組)。 例如,您可以指派自訂安全性屬性來篩選應用程式,或協助判斷可以存取的人員。 本文描述如何指派、更新、列出或移除 Microsoft Entra 企業應用程式的自訂安全性屬性。

必要條件

若要指派或移除 Microsoft Entra 租用戶中的應用程式自訂安全性屬性,您需要有:

重要

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

指派、更新、列出或移除應用程式的自訂屬性

了解如何使用 Microsoft Entra ID 中應用程式的自訂屬性。

將自訂安全性屬性指派給應用程式

提示

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

請執行下列步驟,透過 Microsoft Entra 系統管理中心指派自訂安全性屬性。

  1. 屬性指派系統管理員 (部分機器翻譯) 身分登入 Microsoft Entra 系統管理中心

  2. 瀏覽至 [身分識別]> [應用程式]> [企業應用程式]

  3. 尋找並選取您想要新增自訂安全性屬性的應用程式。

  4. 在 [管理] 區段中,選取 [自訂安全性屬性]

  5. 選取 [新增指派]

  6. 在 [屬性集] 中,從清單中選取屬性集。

  7. 在 [屬性名稱] 中,從清單中選取自訂安全性屬性。

  8. 您可以根據所選自訂安全性屬性的內容,輸入單一值、選取預先定義清單中的值,或新增多個值。

    • 若為自由格式的單一值自訂安全性屬性,請在 [已指派值] 方塊中輸入值。
    • 若為預先定義的自訂安全性屬性值,請從 [已指派值] 清單中選取值。
    • 若為多個值的自訂安全性屬性,請選取 [新增值] 開啟 [屬性值] 窗格,然後新增值。 值新增完成後,請選取 [完成]

    顯示如何將自訂安全性屬性指派給應用程式的螢幕擷取畫面。

  9. 完成後,請選取 [儲存],將自訂安全性屬性指派給應用程式。

更新應用程式的自訂安全性屬性指派值

  1. 屬性指派系統管理員 (部分機器翻譯) 身分登入 Microsoft Entra 系統管理中心

  2. 瀏覽至 [身分識別]> [應用程式]> [企業應用程式]

  3. 尋找並選取有您想要更新之自訂安全性屬性指派值的應用程式。

  4. 在 [管理] 區段中,選取 [自訂安全性屬性]

  5. 尋找您想要更新的自訂安全性屬性指派值。

    將自訂安全性屬性指派給應用程式之後,您就只能變更自訂安全性屬性的值。 不能變更自訂安全性屬性的其他內容,例如屬性集或自訂安全性屬性名稱。

  6. 根據所選自訂安全性屬性的內容,您可以更新單一值、選取預先定義清單中的值,或更新多個值。

  7. 完成後,請選取儲存

根據自訂安全性屬性篩選應用程式

您可以在 [所有應用程式] 頁面上,篩選指派給應用程式的自訂安全性屬性清單。

  1. 至少以屬性指派系統讀取者 (部分機器翻譯) 身分登入 Microsoft Entra 系統管理中心

  2. 瀏覽至 [身分識別]> [應用程式]> [企業應用程式]

  3. 選取 [新增篩選] 以開啟 [挑選欄位] 窗格。

    如果您沒有看到 [新增篩選],請選取橫幅以啟用企業應用程式搜尋預覽。

  4. 針對 [篩選] 選取 [自訂安全性屬性]

  5. 選取屬性集和屬性名稱。

  6. 針對 [運算子],您可以選取等於 (==)、不等於 (!=),或開頭值

  7. 在 [值] 中輸入或選取值。

    顯示應用程式的自訂安全性屬性篩選條件的螢幕擷取畫面。

  8. 若要套用篩選,請選取 [套用]

移除應用程式的自訂安全性屬性指派

  1. 屬性指派系統管理員 (部分機器翻譯) 身分登入 Microsoft Entra 系統管理中心

  2. 瀏覽至 [身分識別]> [應用程式]> [企業應用程式]

  3. 尋找並選取有您想要移除之自訂安全性屬性指派的應用程式。

  4. 在 [管理] 區段中,選取 [自訂安全性屬性 (預覽)]

  5. 在您想要移除的所有自訂安全性屬性指派旁邊,新增核取記號。

  6. 選取 [移除指派]

Azure AD PowerShell

您可以使用 PowerShell 來管理 Microsoft Entra 組織中的應用程式自訂安全性屬性指派。 您可以使用下列命令來管理指派。

使用 Azure AD PowerShell 將具有多字串值的自訂安全性屬性指派給應用程式 (服務主體)

您可以使用 AzureADMSServicePrincipal 命令,將具有多重字串值的自訂安全性屬性指派給應用程式 (服務主體)。

  • 屬性集:Engineering
  • 屬性:Project
  • 屬性資料類型:字串集合
  • 屬性值:("Baker","Cascade")
$attributes = @{
    Engineering = @{
        "@odata.type" = "#Microsoft.DirectoryServices.CustomSecurityAttributeValue"
        "Project@odata.type" = "#Collection(String)"
        Project = @("Baker","Cascade")
    }
}
Set-AzureADMSServicePrincipal -Id aaaaaaaa-bbbb-cccc-1111-222222222222 -CustomSecurityAttributes $attributes

使用 Azure AD PowerShell 針對應用程式 (服務主體) 更新具有多字串值的自訂安全性屬性指派

提供您想要在應用程式上反映的一組新屬性值。 在此範例中,我們會為專案屬性新增一個額外的值。

  • 屬性集:Engineering
  • 屬性:Project
  • 屬性資料類型:字串集合
  • 屬性值:("Alpine","Baker")
$attributesUpdate = @{
    Engineering = @{
        "@odata.type" = "#Microsoft.DirectoryServices.CustomSecurityAttributeValue"
        "Project@odata.type" = "#Collection(String)"
        Project = @("Alpine","Baker")
    }
}
Set-AzureADMSServicePrincipal -Id aaaaaaaa-bbbb-cccc-1111-222222222222 -CustomSecurityAttributes $attributesUpdate 

使用 Azure AD PowerShell 取得應用程式 (服務主體) 的自訂安全性屬性指派。

使用 AzureADMSServicePrincipal 命令可取得應用程式 (服務主體) 的自訂安全性屬性指派。

Get-AzureADMSServicePrincipal -Select CustomSecurityAttributes
Get-AzureADMSServicePrincipal -Id aaaaaaaa-bbbb-cccc-1111-222222222222  -Select "CustomSecurityAttributes, Id"

Microsoft Graph/PowerShell

您可以使用 Microsoft Graph PowerShell 來管理 Microsoft Entra 組織中的應用程式自訂安全性屬性指派。 您可以使用下列命令來管理指派。

使用 Microsoft Graph PowerShell 將具有多字串值的自訂安全性屬性指派給應用程式 (服務主體)

您可以使用 Update-MgServicePrincipal (英文) 命令,將具有多重字串值的自訂安全性屬性指派給應用程式 (服務主體)。

指定值

  • 屬性集:Engineering
  • 屬性:ProjectDate
  • 屬性資料類型:字串
  • 屬性值:"2024-11-15"
#Retrieve the servicePrincipal

$ServicePrincipal = (Get-MgServicePrincipal -Filter "displayName eq 'TestApp'").Id

$customSecurityAttributes = @{
    Engineering = @{
        "@odata.type" = "#Microsoft.DirectoryServices.CustomSecurityAttributeValue"
        "ProjectDate" ="2024-11-15"
    }
}
Update-MgServicePrincipal -ServicePrincipalId $ServicePrincipal -CustomSecurityAttributes $customSecurityAttributes

使用 Microsoft Graph PowerShell 針對應用程式 (服務主體) 更新具有多字串值的自訂安全性屬性指派

提供您想要在應用程式上反映的一組新屬性值。 在此範例中,我們會為專案屬性新增一個額外的值。

指定值

  • 屬性集:Engineering
  • 屬性:Project
  • 屬性資料類型:字串集合
  • 屬性值:["Baker","Cascade"]
$customSecurityAttributes = @{
    Engineering = @{
        "@odata.type" = "#Microsoft.DirectoryServices.CustomSecurityAttributeValue"
        "Project@odata.type" = "#Collection(String)"
        "Project" = @(
            "Baker"
            "Cascade"
        )
    }
}
Update-MgServicePrincipal -ServicePrincipalId $ServicePrincipal -CustomSecurityAttributes $customSecurityAttributes

使用 Microsoft Graph PowerShell 根據自訂安全性屬性篩選應用程式

此範例會篩選具有等於指定值之自訂安全性屬性指派的應用程式清單。

$appAttributes = Get-MgServicePrincipal -CountVariable CountVar -Property "id,displayName,customSecurityAttributes" -Filter "customSecurityAttributes/Engineering/Project eq 'Baker'" -ConsistencyLevel eventual
$appAttributes | select Id,DisplayName,CustomSecurityAttributes  | Format-List
$appAttributes.CustomSecurityAttributes.AdditionalProperties | Format-List
Id                       : aaaaaaaa-bbbb-cccc-1111-222222222222
DisplayName              : TestApp
CustomSecurityAttributes : Microsoft.Graph.PowerShell.Models.MicrosoftGraphCustomSecurityAttributeValue

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

使用 Microsoft Graph PowerShell 移除應用程式的自訂安全性屬性指派

在此範例中,我們會移除支援單一值的自訂安全性屬性指派。


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

在此範例中,我們會移除支援多個值的自訂安全性屬性指派。

$customSecurityAttributes = @{
    Engineering = @{
        "@odata.type" = "#Microsoft.DirectoryServices.CustomSecurityAttributeValue"
        "Project" = @()
    }
}
Update-MgServicePrincipal -ServicePrincipalId $ServicePrincipal -CustomSecurityAttributes $customSecurityAttributes

Microsoft Graph API

您可以使用 Microsoft Graph API 來管理 Microsoft Entra 組織中的應用程式自訂安全性屬性指派。 進行下列 API 呼叫來管理指派。

如需使用者的其他類似 Microsoft Graph API 範例,請參閱指派、更新、列出或移除使用者的自訂安全性屬性 (部分機器翻譯),以及範例:使用 Microsoft Graph API 指派、更新、列出或移除自訂安全性屬性指派 (英文)。

使用 Microsoft Graph API 將具有多字串值的自訂安全性屬性指派給應用程式 (服務主體)

使用 Update servicePrincipal (英文) API 將具有一個字串值的自訂安全性屬性指派至應用程式。

指定值

  • 屬性集:Engineering
  • 屬性:Project
  • 屬性資料類型:字串
  • 屬性值:"Baker"
PATCH https://graph.microsoft.com/v1.0/servicePrincipals/{id}
Content-type: application/json

{
    "customSecurityAttributes":
    {
        "Engineering":
        {
            "@odata.type":"#Microsoft.DirectoryServices.CustomSecurityAttributeValue",
            "Project@odata.type":"#Collection(String)",
            "Project": "Baker"
        }
    }
}

使用 Microsoft Graph API 針對應用程式 (服務主體) 更新具有多字串值的自訂安全性屬性指派

提供您想要在應用程式上反映的一組新屬性值。 在此範例中,我們會為專案屬性新增一個額外的值。

PATCH https://graph.microsoft.com/v1.0/servicePrincipals/{id}
Content-type: application/json

{
    "customSecurityAttributes":
    {
        "Engineering":
        {
            "@odata.type":"#Microsoft.DirectoryServices.CustomSecurityAttributeValue",
            "Project@odata.type":"#Collection(String)",
            "Project":["Baker","Cascade"]
        }
    }
}

使用 Microsoft Graph API 根據自訂安全性屬性篩選應用程式

此範例會篩選具有等於指定值之自訂安全性屬性指派的應用程式清單。 篩選值會區分大小寫。 您必須在要求或標頭中新增 ConsistencyLevel=eventual。 您也必須包含 $count=true,確保正確路由要求。

GET https://graph.microsoft.com/v1.0/servicePrincipals?$count=true&$select=id,displayName,customSecurityAttributes&$filter=customSecurityAttributes/Engineering/Project eq 'Baker'
ConsistencyLevel: eventual

使用 Microsoft Graph API 移除應用程式的自訂安全性屬性指派

在此範例中,我們會移除支援多個值的自訂安全性屬性指派。

PATCH https://graph.microsoft.com/v1.0/servicePrincipals/{id}
Content-type: application/json

{
    "customSecurityAttributes":
    {
        "Engineering":
        {
            "@odata.type":"#Microsoft.DirectoryServices.CustomSecurityAttributeValue",
            "Project":[]
        }
    }
}

下一步