Skip to content

Commit fe1c1c5

Browse files
authored
Merge pull request #240267 from rolyon/rolyon-abac-attributes-graph-powershell
[Azure AD] Custom security attributes Microsoft Graph PowerShell examples
2 parents 783f0b8 + 0851c04 commit fe1c1c5

File tree

8 files changed

+1475
-244
lines changed

8 files changed

+1475
-244
lines changed

articles/active-directory/enterprise-users/users-custom-security-attributes.md

Lines changed: 705 additions & 74 deletions
Large diffs are not rendered by default.

articles/active-directory/fundamentals/custom-security-attributes-add.md

Lines changed: 693 additions & 147 deletions
Large diffs are not rendered by default.

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

Lines changed: 65 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ ms.service: active-directory
99
ms.subservice: fundamentals
1010
ms.workload: identity
1111
ms.topic: how-to
12-
ms.date: 01/07/2023
12+
ms.date: 06/29/2023
1313
ms.collection: M365-identity-device-management
1414
---
1515

@@ -27,13 +27,14 @@ To manage access to custom security attributes, you must have:
2727

2828
- Azure AD Premium P1 or P2 license
2929
- [Attribute Assignment Administrator](../roles/permissions-reference.md#attribute-assignment-administrator)
30+
- Microsoft.Graph module when using [Microsoft Graph PowerShell](/powershell/microsoftgraph/installation)
3031

3132
> [!IMPORTANT]
3233
> 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.
3334
3435
## Step 1: Figure out how to organize your attributes
3536

36-
Every custom security attribute must be part of an attribute set. An attribute set is a way to group and manage related custom security attributes. You'll need to figure out how you want to add attributes sets for your organization. For example, you might want to add attribute sets based on departments, teams, or projects. Your ability to grant access to custom security attributes will depend on how you organize your attribute sets.
37+
Every custom security attribute definition must be part of an attribute set. An attribute set is a way to group and manage related custom security attributes. You'll need to figure out how you want to add attributes sets for your organization. For example, you might want to add attribute sets based on departments, teams, or projects. Your ability to grant access to custom security attributes will depend on how you organize your attribute sets.
3738

3839
![Diagram showing an attribute set by department.](./media/custom-security-attributes-manage/attribute-set-department.png)
3940

@@ -111,7 +112,9 @@ To grant access to the appropriate people, follow these steps to assign one of t
111112

112113
### Assign roles at attribute set scope
113114

114-
#### Azure portal
115+
The following examples show how to assign a custom security attribute role to a principal at an attribute set scope named Engineering.
116+
117+
# [Portal](#tab/azure-portal)
115118

116119
1. Sign in to the [Azure portal](https://portal.azure.com).
117120

@@ -130,20 +133,20 @@ To grant access to the appropriate people, follow these steps to assign one of t
130133
> [!NOTE]
131134
> If you are using Azure AD Privileged Identity Management (PIM), eligible role assignments at attribute set scope currently aren't supported. Permanent role assignments at attribute set scope are supported, but the **Assigned roles** page for a user doesn't list the role assignments.
132135
133-
#### PowerShell
136+
# [PowerShell](#tab/ms-powershell)
134137

135-
Use [New-AzureADMSRoleAssignment](/powershell/module/azuread/new-azureadmsroleassignment) to assign the role. The following example assigns the Attribute Assignment Administrator role to a principal with an attribute set scope named Engineering.
138+
[New-MgRoleManagementDirectoryRoleAssignment](/powershell/module/microsoft.graph.devicemanagement.enrolment/new-mgrolemanagementdirectoryroleassignment)
136139

137140
```powershell
138141
$roleDefinitionId = "58a13ea3-c632-46ae-9ee0-9c0d43cd7f3d"
139-
$directoryScope = "/attributeSets/Engineering"
140142
$principalId = "f8ca5a85-489a-49a0-b555-0a6d81e56f0d"
141-
$roleAssignment = New-AzureADMSRoleAssignment -DirectoryScopeId $directoryScope -RoleDefinitionId $roleDefinitionId -PrincipalId $principalId
143+
$directoryScopeId = "/attributeSets/Engineering"
144+
$roleAssignment = New-MgRoleManagementDirectoryRoleAssignment -RoleDefinitionId $roleDefinitionId -PrincipalId $principalId -DirectoryScopeId $directoryScopeId
142145
```
143146

144-
#### Microsoft Graph API
147+
# [Microsoft Graph](#tab/ms-graph)
145148

146-
Use the [Create unified Role Assignment](/graph/api/rbacapplication-post-roleassignments?view=graph-rest-beta&preserve-view=true) API to assign the role. The following example assigns the Attribute Assignment Administrator role to a principal with an attribute set scope named Engineering.
149+
[Create unifiedRoleAssignment](/graph/api/rbacapplication-post-roleassignments)
147150

148151
```http
149152
POST https://graph.microsoft.com/beta/roleManagement/directory/roleAssignments
@@ -157,9 +160,24 @@ Content-type: application/json
157160
}
158161
```
159162

163+
# [Azure AD PowerShell](#tab/aad-powershell)
164+
165+
[New-AzureADMSRoleAssignment](/powershell/module/azuread/new-azureadmsroleassignment)
166+
167+
```powershell
168+
$roleDefinitionId = "58a13ea3-c632-46ae-9ee0-9c0d43cd7f3d"
169+
$principalId = "f8ca5a85-489a-49a0-b555-0a6d81e56f0d"
170+
$directoryScope = "/attributeSets/Engineering"
171+
$roleAssignment = New-AzureADMSRoleAssignment -RoleDefinitionId $roleDefinitionId -PrincipalId $principalId -DirectoryScopeId $directoryScope
172+
```
173+
174+
---
175+
160176
### Assign roles at tenant scope
161177

162-
#### Azure portal
178+
The following examples show how to assign a custom security attribute role to a principal at tenant scope.
179+
180+
# [Portal](#tab/azure-portal)
163181

164182
1. Sign in to the [Azure portal](https://portal.azure.com).
165183

@@ -171,13 +189,45 @@ Content-type: application/json
171189

172190
1. Add assignments for the custom security attribute roles.
173191

174-
#### PowerShell
192+
# [PowerShell](#tab/ms-powershell)
193+
194+
[New-MgRoleManagementDirectoryRoleAssignment](/powershell/module/microsoft.graph.devicemanagement.enrolment/new-mgrolemanagementdirectoryroleassignment)
195+
196+
```powershell
197+
$roleDefinitionId = "58a13ea3-c632-46ae-9ee0-9c0d43cd7f3d"
198+
$principalId = "f8ca5a85-489a-49a0-b555-0a6d81e56f0d"
199+
$directoryScopeId = "/"
200+
$roleAssignment = New-MgRoleManagementDirectoryRoleAssignment -RoleDefinitionId $roleDefinitionId -PrincipalId $principalId -DirectoryScopeId $directoryScopeId
201+
```
202+
203+
# [Microsoft Graph](#tab/ms-graph)
175204

176-
Use [New-AzureADMSRoleAssignment](/powershell/module/azuread/new-azureadmsroleassignment) to assign the role. For more information, see [Assign Azure AD roles at different scopes](../roles/assign-roles-different-scopes.md).
205+
[Create unifiedRoleAssignment](/graph/api/rbacapplication-post-roleassignments)
177206

178-
#### Microsoft Graph API
207+
```http
208+
POST https://graph.microsoft.com/beta/roleManagement/directory/roleAssignments
209+
Content-type: application/json
179210
180-
Use the [Create unified Role Assignment](/graph/api/rbacapplication-post-roleassignments?view=graph-rest-beta&preserve-view=true) API to assign the role. For more information, see [Assign Azure AD roles at different scopes](../roles/assign-roles-different-scopes.md).
211+
{
212+
"@odata.type": "#microsoft.graph.unifiedRoleAssignment",
213+
"roleDefinitionId": "58a13ea3-c632-46ae-9ee0-9c0d43cd7f3d",
214+
"principalId": "f8ca5a85-489a-49a0-b555-0a6d81e56f0d",
215+
"directoryScopeId": "/"
216+
}
217+
```
218+
219+
# [Azure AD PowerShell](#tab/aad-powershell)
220+
221+
[New-AzureADMSRoleAssignment](/powershell/module/azuread/new-azureadmsroleassignment)
222+
223+
```powershell
224+
$roleDefinitionId = "58a13ea3-c632-46ae-9ee0-9c0d43cd7f3d"
225+
$principalId = "f8ca5a85-489a-49a0-b555-0a6d81e56f0d"
226+
$directoryScope = "/"
227+
$roleAssignment = New-AzureADMSRoleAssignment -RoleDefinitionId $roleDefinitionId -PrincipalId $principalId -DirectoryScopeId $directoryScope
228+
```
229+
230+
---
181231

182232
## View audit logs for attribute changes
183233

@@ -198,6 +248,6 @@ The following screenshot shows an example of the audit log. To filter the logs f
198248

199249
## Next steps
200250

201-
- [Add or deactivate custom security attributes in Azure AD](custom-security-attributes-add.md)
251+
- [Add or deactivate custom security attribute definitions in Azure AD](custom-security-attributes-add.md)
202252
- [Assign, update, list, or remove custom security attributes for a user](../enterprise-users/users-custom-security-attributes.md)
203253
- [Troubleshoot custom security attributes in Azure AD](custom-security-attributes-troubleshoot.md)

articles/active-directory/fundamentals/custom-security-attributes-overview.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ ms.service: active-directory
99
ms.subservice: fundamentals
1010
ms.workload: identity
1111
ms.topic: conceptual
12-
ms.date: 05/09/2022
12+
ms.date: 06/29/2023
1313
ms.collection: M365-identity-device-management
1414
---
1515

@@ -201,6 +201,6 @@ Depending on whether you have an Azure AD Premium P1 or P2 license, here are the
201201

202202
## Next steps
203203

204-
- [Add or deactivate custom security attributes in Azure AD](custom-security-attributes-add.md)
204+
- [Add or deactivate custom security attribute definitions in Azure AD](custom-security-attributes-add.md)
205205
- [Manage access to custom security attributes in Azure AD](custom-security-attributes-manage.md)
206206
- [Assign, update, list, or remove custom security attributes for a user](../enterprise-users/users-custom-security-attributes.md)

articles/active-directory/fundamentals/custom-security-attributes-troubleshoot.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ ms.service: active-directory
99
ms.subservice: fundamentals
1010
ms.workload: identity
1111
ms.topic: how-to
12-
ms.date: 02/20/2023
12+
ms.date: 06/29/2023
1313
ms.collection: M365-identity-device-management
1414
---
1515

@@ -27,7 +27,7 @@ When signed in to the Azure portal as Global Administrator and you try to access
2727

2828
**Cause**
2929

30-
Custom security attributes requires an Azure AD Premium P1 or P2 license.
30+
Custom security attributes require an Azure AD Premium P1 or P2 license.
3131

3232
**Solution**
3333

@@ -91,7 +91,7 @@ There are no custom security attributes defined and assigned yet for your tenant
9191

9292
**Solution 3**
9393

94-
Add and assign custom security attributes to users or enterprise applications. For more information, see [Add or deactivate custom security attributes in Azure AD](custom-security-attributes-add.md), [Assign, update, list, or remove custom security attributes for a user](../enterprise-users/users-custom-security-attributes.md), or [Assign, update, list, or remove custom security attributes for an application](../manage-apps/custom-security-attributes-apps.md).
94+
Add and assign custom security attributes to users or enterprise applications. For more information, see [Add or deactivate custom security attribute definitions in Azure AD](custom-security-attributes-add.md), [Assign, update, list, or remove custom security attributes for a user](../enterprise-users/users-custom-security-attributes.md), or [Assign, update, list, or remove custom security attributes for an application](../manage-apps/custom-security-attributes-apps.md).
9595

9696
## Symptom - Custom security attributes cannot be deleted
9797

@@ -101,7 +101,7 @@ Currently, you can only activate and deactivate custom security attribute defini
101101

102102
**Solution**
103103

104-
Deactivate the custom security attributes you no longer need. For more information, see [Add or deactivate custom security attributes in Azure AD](custom-security-attributes-add.md).
104+
Deactivate the custom security attributes you no longer need. For more information, see [Add or deactivate custom security attribute definitions in Azure AD](custom-security-attributes-add.md).
105105

106106
## Symptom - Cannot add a role assignment at an attribute set scope using PIM
107107

14.5 KB
Loading

articles/active-directory/fundamentals/toc.yml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,10 +127,14 @@ items:
127127
items:
128128
- name: What are custom security attributes
129129
href: custom-security-attributes-overview.md
130-
- name: Add or deactivate attributes
130+
- name: Add or deactivate attribute definitions
131131
href: custom-security-attributes-add.md
132132
- name: Manage access to attributes
133133
href: custom-security-attributes-manage.md
134+
- name: Assign attributes to users
135+
href: ../enterprise-users/users-custom-security-attributes.md?toc=/azure/active-directory/fundamentals/toc.json
136+
- name: Assign attributes to applications
137+
href: ../manage-apps/custom-security-attributes-apps.md?toc=/azure/active-directory/fundamentals/toc.json
134138
- name: Troubleshoot attributes
135139
href: custom-security-attributes-troubleshoot.md
136140
- name: Frontline worker management

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -268,7 +268,7 @@ Update-MgServicePrincipal -ServicePrincipalId $ServicePrincipal -BodyParameter $
268268

269269
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.
270270

271-
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).
271+
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#powershell-or-microsoft-graph-api) and [Examples: Assign, update, list, or remove custom security attribute assignments using the Microsoft Graph API](/graph/custom-security-attributes-examples).
272272

273273
### Assign a custom security attribute with a multi-string value to an application (service principal)
274274

0 commit comments

Comments
 (0)