Skip to content

Commit b953b99

Browse files
committed
update powershell and graph API content
1 parent 7ade4ec commit b953b99

File tree

1 file changed

+161
-32
lines changed

1 file changed

+161
-32
lines changed

articles/active-directory/manage-apps/custom-security-attributes-apps.md

Lines changed: 161 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,11 @@ ms.service: active-directory
77
ms.subservice: app-mgmt
88
ms.topic: how-to
99
ms.workload: identity
10-
ms.date: 02/20/2023
10+
ms.date: 02/28/2023
1111
ms.author: jomondi
1212
ms.reviewer: rolyon
13+
zone_pivot_groups: enterprise-apps-all
14+
1315
---
1416

1517
# Assign, update, list, or remove custom security attributes for an application (Preview)
@@ -26,18 +28,21 @@ To assign or remove custom security attributes for an application in your Azure
2628

2729
- Azure AD Premium P1 or P2 license
2830
- [Attribute Assignment Administrator](../roles/permissions-reference.md#attribute-assignment-administrator)
29-
- [AzureADPreview](https://www.powershellgallery.com/packages/AzureADPreview) version 2.0.2.138 or later when using PowerShell
31+
- Make sure you have existing custom security attributes. To learn how to create a security attribute, see [Add or deactivate custom security attributes in Azure AD](../fundamentals/custom-security-attributes-add.md).
32+
3033

3134
> [!IMPORTANT]
32-
> By default, [Global Administrator](../roles/permissions-reference.md#global-administrator) and other administrator roles do not have permissions to read, define, or assign custom security attributes.
35+
> By default, [Global Administrator](../roles/permissions-reference.md#global-administrator) and other administrator roles don't have permissions to read, define, or assign custom security attributes.
3336
3437
## Assign custom security attributes to an application
3538

36-
1. Sign in to the [Azure portal](https://portal.azure.com) or [Azure AD admin center](https://aad.portal.azure.com).
39+
:::zone pivot="portal"
3740

38-
1. Make sure that you have existing custom security attributes. For more information, see [Add or deactivate custom security attributes in Azure AD](../fundamentals/custom-security-attributes-add.md).
41+
Undertake the following steps to assign custom security attributes through the Azure portal.
42+
43+
1. Sign in to the [Azure portal](https://portal.azure.com) or [Azure AD admin center](https://aad.portal.azure.com).
3944

40-
1. Select **Azure Active Directory** > **Enterprise applications**.
45+
1. Select **Azure Active Directory**, then select **Enterprise applications**.
4146

4247
1. Find and select the application you want to add a custom security attribute to.
4348

@@ -55,39 +60,39 @@ To assign or remove custom security attributes for an application in your Azure
5560
- For predefined custom security attribute values, select a value from the **Assigned values** list.
5661
- For multi-valued custom security attributes, select **Add values** to open the **Attribute values** pane and add your values. When finished adding values, select **Done**.
5762

58-
![Screenshot showing assigning a custom security attribute to an application.](./media/custom-security-attributes-apps/apps-attributes-assign.png)
63+
![Screenshot shows how to assign a custom security attribute to an application.](./media/custom-security-attributes-apps/apps-attributes-assign.png)
5964

6065
1. When finished, select **Save** to assign the custom security attributes to the application.
6166

6267
## Update custom security attribute assignment values for an application
6368

6469
1. Sign in to the [Azure portal](https://portal.azure.com) or [Azure AD admin center](https://aad.portal.azure.com).
6570

66-
1. Select **Azure Active Directory** > **Enterprise applications**.
71+
1. Select **Azure Active Directory**, then select **Enterprise applications**.
6772

6873
1. Find and select the application that has a custom security attribute assignment value you want to update.
6974

7075
1. In the Manage section, select **Custom security attributes (preview)**.
7176

7277
1. Find the custom security attribute assignment value you want to update.
7378

74-
Once you have assigned a custom security attribute to an application, you can only change the value of the custom security attribute. You can't change other properties of the custom security attribute, such as attribute set or custom security attribute name.
79+
Once you've assigned a custom security attribute to an application, you can only change the value of the custom security attribute. You can't change other properties of the custom security attribute, such as attribute set or custom security attribute name.
7580

7681
1. Depending on the properties of the selected custom security attribute, you can update a single value, select a value from a predefined list, or update multiple values.
7782

7883
1. When finished, select **Save**.
7984

8085
## Filter applications based on custom security attributes
8186

82-
You can filter the list of custom security attributes assigned to applications on the All applications page.
87+
You can filter the list of custom security attributes assigned to applications on the **All applications** page.
8388

8489
1. Sign in to the [Azure portal](https://portal.azure.com) or [Azure AD admin center](https://aad.portal.azure.com).
8590

86-
1. Select **Azure Active Directory** > **Enterprise applications**.
91+
1. Select **Azure Active Directory**, then select **Enterprise applications**.
8792

8893
1. Select **Add filters** to open the Pick a field pane.
8994

90-
If you don't see Add filters, click the banner to enable the Enterprise applications search preview.
95+
If you don't see **Add filters**, select the banner to enable the Enterprise applications search preview.
9196

9297
1. For **Filters**, select **Custom security attribute**.
9398

@@ -105,21 +110,24 @@ You can filter the list of custom security attributes assigned to applications o
105110

106111
1. Sign in to the [Azure portal](https://portal.azure.com) or [Azure AD admin center](https://aad.portal.azure.com).
107112

108-
1. Select **Azure Active Directory** > **Enterprise applications**.
113+
1. Select **Azure Active Directory**, then select **Enterprise applications**.
109114

110115
1. Find and select the application that has the custom security attribute assignments you want to remove.
111116

112-
1. In the Manage section, select **Custom security attributes (preview)**.
117+
1. In the **Manage** section, select **Custom security attributes (preview)**.
113118

114119
1. Add check marks next to all the custom security attribute assignments you want to remove.
115120

116121
1. Select **Remove assignment**.
117122

123+
:::zone-end
124+
125+
:::zone pivot="aad-powershell"
118126
## PowerShell
119127

120128
To manage custom security attribute assignments for applications in your Azure AD organization, you can use PowerShell. The following commands can be used to manage assignments.
121129

122-
#### Assign a custom security attribute with a multi-string value to an application (service principal)
130+
## Assign a custom security attribute with a multi-string value to an application (service principal)
123131

124132
Use the [Set-AzureADMSServicePrincipal](/powershell/module/azuread/set-azureadmsserviceprincipal) command to assign a custom security attribute with a multi-string value to an application (service principal).
125133

@@ -139,9 +147,9 @@ $attributes = @{
139147
Set-AzureADMSServicePrincipal -Id 7d194b0c-bf17-40ff-9f7f-4b671de8dc20 -CustomSecurityAttributes $attributes
140148
```
141149

142-
#### Update a custom security attribute with a multi-string value for an application (service principal)
150+
## Update a custom security attribute with a multi-string value for an application (service principal)
143151

144-
Use the [Set-AzureADMSServicePrincipal](/powershell/module/azuread/set-azureadmsserviceprincipal) command to update a custom security attribute with a multi-string value for an application (service principal).
152+
Provide the new set of attribute values that you would like to reflect on the application. In this example, we're adding one more value for project attribute.
145153

146154
- Attribute set: `Engineering`
147155
- Attribute: `Project`
@@ -159,7 +167,7 @@ $attributesUpdate = @{
159167
Set-AzureADMSServicePrincipal -Id 7d194b0c-bf17-40ff-9f7f-4b671de8dc20 -CustomSecurityAttributes $attributesUpdate
160168
```
161169

162-
#### Get the custom security attribute assignments for an application (service principal)
170+
## Get the custom security attribute assignments for an application (service principal)
163171

164172
Use the [Get-AzureADMSServicePrincipal](/powershell/module/azuread/get-azureadmsserviceprincipal) command to get the custom security attribute assignments for an application (service principal).
165173

@@ -168,51 +176,172 @@ Get-AzureADMSServicePrincipal -Select CustomSecurityAttributes
168176
Get-AzureADMSServicePrincipal -Id 7d194b0c-bf17-40ff-9f7f-4b671de8dc20 -Select "CustomSecurityAttributes, Id"
169177
```
170178

171-
## Microsoft Graph API
179+
:::zone-end
180+
181+
:::zone pivot="ms-powershell"
182+
183+
To manage custom security attribute assignments for applications in your Azure AD organization, you can use Microsoft Graph PowerShell. The following commands can be used to manage assignments.
184+
185+
## Assign a custom security attribute with a multi-string value to an application (service principal)
186+
187+
Use the [Set-AzureADMSServicePrincipal](/powershell/module/azuread/set-azureadmsserviceprincipal) command to assign a custom security attribute with a multi-string value to an application (service principal).
188+
189+
Given the values
190+
191+
• Attribute set: Engineering
192+
• Attribute: Project
193+
• Attribute data type: String
194+
• Attribute value: "Baker"
195+
196+
```powershell
197+
#Retrieve the servicePrincipal
198+
199+
$ServicePrincipal= (Get-MgServicePrincipal -Filter "displayName eq 'Microsoft Graph'").Id
200+
201+
$params = @{
202+
CustomSecurityAttributes = @{
203+
Engineering =@{
204+
"@odata.type" = "#Microsoft.DirectoryServices.CustomSecurityAttributeValue"
205+
ProjectDate ="Baker"
206+
}
207+
}
208+
}
209+
210+
Update-MgServicePrincipal -ServicePrincipalId $ServicePrincipal -BodyParameter $params
211+
```
212+
213+
## Update a custom security attribute with a multi-string value for an application (service principal)
214+
215+
Provide the new set of attribute values that you would like to reflect on the application. In this example, we're adding one more value for project attribute.
216+
217+
```powershell
218+
$params = @{
219+
CustomSecurityAttributes = @{
220+
Engineering =@{
221+
"@odata.type" = "#Microsoft.DirectoryServices.CustomSecurityAttributeValue"
222+
Project =@(
223+
"Baker"
224+
"Cascade"
225+
)
226+
}
227+
}
228+
}
229+
Update-MgServicePrincipal -ServicePrincipalId $ServicePrincipal -BodyParameter $params
230+
```
231+
232+
## Filter applications based on custom security attributes
233+
234+
This example filters a list of applications with a custom security attribute assignment that equals the specified value.
235+
236+
```powershell
237+
Get-MgServicePrincipal -CountVariable CountVar -Property "id,displayName,customSecurityAttributes" -Filter "customSecurityAttributes/Engineering/Project eq 'Baker'" -ConsistencyLevel eventual
238+
```
239+
240+
## Remove custom security attribute assignments from applications
241+
242+
In this example, we remove a custom security attribute assignment that supports multiple values.
243+
244+
```powershell
245+
$params = @{
246+
CustomSecurityAttributes = @{
247+
Engineering =@{
248+
"@odata.type" = "#Microsoft.DirectoryServices.CustomSecurityAttributeValue"
249+
Project =@(
250+
)
251+
}
252+
}
253+
}
254+
Update-MgServicePrincipal -ServicePrincipalId $ServicePrincipal -BodyParameter $params
255+
```
256+
257+
258+
:::zone-end
259+
260+
:::zone pivot="ms-graph
172261

173-
To manage custom security attribute assignments for applications in your Azure AD organization, you can use the Microsoft Graph API. The following API calls can be made to manage assignments.
262+
To manage custom security attribute assignments for applications in your Azure AD organization, you can use the Microsoft Graph API. Make the following API calls to manage assignments.
174263

175264
For other similar Microsoft Graph API examples for users, see [Assign, update, list, or remove custom security attributes for a user](../enterprise-users/users-custom-security-attributes.md#microsoft-graph-api) and [Examples: Assign, update, list, or remove custom security attribute assignments using the Microsoft Graph API](/graph/custom-security-attributes-examples).
176265

177-
#### Assign a custom security attribute with a string value to an application (service principal)
266+
## Assign a custom security attribute with a multi-string value to an application (service principal)
178267

179-
Use the [Update servicePrincipal](/graph/api/serviceprincipal-update?view=graph-rest-beta&preserve-view=true) API to assign a custom security attribute with a string value to a user.
268+
Use the [Update servicePrincipal](/graph/api/serviceprincipal-update?view=graph-rest-beta&preserve-view=true) API to assign a custom security attribute with a string value to an application.
180269

181-
- Attribute set: `Engineering`
182-
- Attribute: `ProjectDate`
183-
- Attribute data type: String
184-
- Attribute value: `"2022-10-01"`
270+
Given the values
271+
272+
• Attribute set: Engineering
273+
• Attribute: Project
274+
• Attribute data type: Collection of Strings
275+
• Attribute value: Baker"
276+
277+
```http
278+
PATCH https://graph.microsoft.com/beta/servicePrincipals/{id}
279+
Content-type: application/json
280+
281+
{
282+
"customSecurityAttributes":
283+
{
284+
"Engineering":
285+
{
286+
"@odata.type":"#Microsoft.DirectoryServices.CustomSecurityAttributeValue",
287+
"[email protected]":"#Collection(String)",
288+
"Project": "Baker"
289+
}
290+
}
291+
}
292+
```
293+
294+
## Update a custom security attribute with a multi-string value for an application (service principal)
295+
296+
Provide the new set of attribute values that you would like to reflect on the application. In this example, we're adding one more value for project attribute.
185297

186298
```http
187299
PATCH https://graph.microsoft.com/beta/servicePrincipals/{id}
300+
Content-type: application/json
301+
188302
{
189303
"customSecurityAttributes":
190304
{
191305
"Engineering":
192306
{
193307
"@odata.type":"#Microsoft.DirectoryServices.CustomSecurityAttributeValue",
194-
"ProjectDate":"2022-10-01"
308+
"[email protected]":"#Collection(String)",
309+
"Project":["Baker","Cascade"]
195310
}
196311
}
197312
}
198313
```
199314

200-
#### Get the custom security attribute assignments for an application (service principal)
315+
## Filter applications based on custom security attributes
201316

202-
Use the [Get servicePrincipal](/graph/api/serviceprincipal-get?view=graph-rest-beta&preserve-view=true) API to get the custom security attribute assignments for an application (service principal).
317+
This example filters a list of applications with a custom security attribute assignment that equals the specified value.
203318

204319
```http
205-
GET https://graph.microsoft.com/beta/servicePrincipals/{id}?$select=customSecurityAttributes
320+
GET https://graph.microsoft.com/beta/servicePrincipals?$count=true&$select=id,displayName,customSecurityAttributes&$filter=customSecurityAttributes/Engineering/Project eq 'Baker'ConsistencyLevel: eventual
206321
```
207322

208-
If there are no custom security attributes assigned to the application or if the calling principal does not have access, the response will look like:
323+
## Remove custom security attribute assignments from an application
324+
325+
In this example, we remove a custom security attribute assignment that supports multiple values.
209326

210327
```http
328+
PATCH https://graph.microsoft.com/beta/servicePrincipals/{id}
329+
Content-type: application/json
330+
211331
{
212-
"customSecurityAttributes": null
332+
"customSecurityAttributes":
333+
{
334+
"Engineering":
335+
{
336+
"@odata.type":"#Microsoft.DirectoryServices.CustomSecurityAttributeValue",
337+
"Project":[]
338+
}
339+
}
213340
}
214341
```
215342

343+
:::zone-end
344+
216345
## Next steps
217346

218347
- [Add or deactivate custom security attributes in Azure AD](../fundamentals/custom-security-attributes-add.md)

0 commit comments

Comments
 (0)