管理應用程式的自定義安全性屬性
Microsoft Entra ID 中的自訂安全性屬性 是商務特定屬性(索引鍵/值組),您可以定義並指派給 Microsoft Entra 物件。 例如,您可以指派自定義安全性屬性來篩選您的應用程式,或協助判斷誰取得存取權。 本文說明如何指派、更新、列出或移除 Microsoft Entra 企業應用程式的自定義安全性屬性。
必要條件
若要為 Microsoft Entra 租使用者中的應用程式指派或移除自訂安全性屬性,您需要:
- 屬性指派 管理員 istrator
- 請確定您有現有的自訂安全性屬性。 若要瞭解如何建立安全性屬性,請參閱 在 Microsoft Entra ID 中新增或停用自定義安全性屬性。
重要
根據預設,全域 管理員 istrator 和其他系統管理員角色沒有讀取、定義或指派自定義安全性屬性的許可權。
指派、更新、列出或移除應用程式的自定義屬性
瞭解如何在 Microsoft Entra ID 中使用應用程式的自定義屬性。
將自訂安全性屬性指派給應用程式
提示
本文中的步驟可能會根據您從開始的入口網站稍有不同。
請執行下列步驟,透過 Microsoft Entra 系統管理中心指派自定義安全性屬性。
以屬性指派 管理員 istrator 身分登入 Microsoft Entra 系統管理中心。
流覽至 [身分>識別應用程式企業應用程式]。>
尋找並選取您要新增自訂安全性屬性的應用程式。
在 [管理] 區段中,選取 [ 自定義安全性屬性]。
選取 [ 新增指派]。
在 [ 屬性集] 中,從清單中選取屬性集。
在 [ 屬性名稱] 中,從清單中選取自定義安全性屬性。
根據所選自定義安全性屬性的屬性,您可以輸入單一值、從預先定義的清單中選取值,或新增多個值。
- 針對手繪多邊形、單一值自定義安全性屬性,請在 [ 指派的值] 方塊中輸入值 。
- 針對預先定義的自定義安全性屬性值,請從 [ 指派的值] 清單中選取值 。
- 針對多重值自定義安全性屬性,選取 [新增值 ] 以開啟 [屬性值 ] 窗格並新增您的值。 完成新增值時,請選取 [ 完成]。
完成後,選取 [ 儲存 ] 將自定義安全性屬性指派給應用程式。
更新應用程式的自定義安全性屬性指派值
以屬性指派 管理員 istrator 身分登入 Microsoft Entra 系統管理中心。
流覽至 [身分>識別應用程式企業應用程式]。>
尋找並選取具有您要更新之自定義安全性屬性指派值的應用程式。
在 [管理] 區段中,選取 [ 自定義安全性屬性]。
尋找您想要更新的自訂安全性屬性指派值。
將自訂安全性屬性指派給應用程式之後,您就只能變更自定義安全性屬性的值。 您無法變更自定義安全性屬性的其他屬性,例如屬性集或自定義安全性屬性名稱。
視所選自定義安全性屬性的屬性而定,您可以更新單一值、從預先定義的清單中選取值,或更新多個值。
完成後,請選取儲存。
根據自訂安全性屬性篩選應用程式
您可以在[所有應用程式] 頁面上篩選指派給應用程式的自訂安全性屬性清單。
以至少屬性指派讀取器身分登入 Microsoft Entra 系統管理中心。
流覽至 [身分>識別應用程式企業應用程式]。>
選取 [新增篩選 ] 以開啟 [挑選字段] 窗格。
如果您沒有看到 [ 新增篩選],請選取橫幅以啟用企業應用程式搜尋預覽。
針對 [ 篩選],選取 [ 自定義安全性屬性]。
選取您的屬性集和屬性名稱。
針對 [運算符],您可以選取等於 (==)、不等於 (!=),或 開頭為 。
針對 [ 值],輸入或選取值。
若要套用篩選,請選取 [ 套用]。
從應用程式移除自定義安全性屬性指派
以屬性指派 管理員 istrator 身分登入 Microsoft Entra 系統管理中心。
流覽至 [身分>識別應用程式企業應用程式]。>
尋找並選取具有您想要移除之自定義安全性屬性指派的應用程式。
在 [管理] 區段中,選取 [自定義安全性屬性][預覽]。
在您想要移除的所有自訂安全性屬性指派旁邊新增複選標記。
選取 [ 移除指派]。
Azure AD PowerShell
若要管理 Microsoft Entra 組織中應用程式的自定義安全性屬性指派,您可以使用 PowerShell。 下列命令可用來管理指派。
使用 Azure AD PowerShell 將具有多字串值的自訂安全性屬性指派給應用程式 (服務主體)
使用 Set-AzureADMSServicePrincipal 命令,將具有多字串值的自定義安全性屬性指派給應用程式(服務主體)。
- 屬性集:
Engineering
- 屬性:
Project
- 屬性數據類型:字串集合
- 屬性值:
("Baker","Cascade")
$attributes = @{
Engineering = @{
"@odata.type" = "#Microsoft.DirectoryServices.CustomSecurityAttributeValue"
"Project@odata.type" = "#Collection(String)"
Project = @("Baker","Cascade")
}
}
Set-AzureADMSServicePrincipal -Id 7d194b0c-bf17-40ff-9f7f-4b671de8dc20 -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 7d194b0c-bf17-40ff-9f7f-4b671de8dc20 -CustomSecurityAttributes $attributesUpdate
使用 Azure AD PowerShell 取得應用程式 (服務主體) 的自定義安全性屬性指派
使用 Get-AzureADMSServicePrincipal 命令來取得應用程式 (服務主體) 的自定義安全性屬性指派。
Get-AzureADMSServicePrincipal -Select CustomSecurityAttributes
Get-AzureADMSServicePrincipal -Id 7d194b0c-bf17-40ff-9f7f-4b671de8dc20 -Select "CustomSecurityAttributes, Id"
Microsoft Graph PowerShell
若要管理 Microsoft Entra 組織中應用程式的自定義安全性屬性指派,您可以使用 Microsoft Graph PowerShell。 下列命令可用來管理指派。
使用 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 : 7d194b0c-bf17-40ff-9f7f-4b671de8dc20
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 Entra 組織中應用程式的自定義安全性屬性指派,您可以使用 Microsoft Graph API。 進行下列 API 呼叫來管理指派。
如需使用者的其他類似 Microsoft Graph 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":[]
}
}
}