Skip to content

Commit 00912b6

Browse files
committed
add check for accountEnabled
1 parent b638f40 commit 00912b6

File tree

1 file changed

+18
-6
lines changed

1 file changed

+18
-6
lines changed

articles/active-directory/governance/identity-governance-applications-existing-users.md

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -234,6 +234,7 @@ The first time your organization uses these cmdlets for this scenario, you need
234234
$dbu_match_ambiguous_list = @()
235235
$dbu_query_failed_list = @()
236236
$azuread_match_id_list = @()
237+
$azuread_not_enabled_list = @()
237238
$dbu_values = @()
238239
$dbu_duplicate_list = @()
239240
@@ -244,10 +245,11 @@ The first time your organization uses these cmdlets for this scenario, you need
244245
if ($dbu_values -contains $escval) { $dbu_duplicate_list += $dbu; continue } else { $dbu_values += $escval }
245246
$filter = $azuread_match_attr_name + " eq '" + $escval + "'"
246247
try {
247-
$ul = @(Get-MgUser -Filter $filter -All -ErrorAction Stop)
248+
$ul = @(Get-MgUser -Filter $filter -All -Property Id,accountEnabled -ErrorAction Stop)
248249
if ($ul.length -eq 0) { $dbu_not_matched_list += $dbu; } elseif ($ul.length -gt 1) {$dbu_match_ambiguous_list += $dbu } else {
249250
$id = $ul[0].id;
250251
$azuread_match_id_list += $id;
252+
if ($ul[0].accountEnabled -eq $false) {$azuread_not_enabled_list += $id }
251253
}
252254
} catch { $dbu_query_failed_list += $dbu }
253255
} else { $dbu_not_queried_list += $dbu }
@@ -280,7 +282,11 @@ The first time your organization uses these cmdlets for this scenario, you need
280282
if ($dbu_query_failed_count -ne 0) {
281283
Write-Error "Unable to locate $dbu_query_failed_count records in Azure AD as queries returned errors."
282284
}
283-
if ($dbu_not_queried_count -ne 0 -or $dbu_duplicate_count -ne 0 -or $dbu_not_matched_count -ne 0 -or $dbu_match_ambiguous_count -ne 0 -or $dbu_query_failed_count -ne 0) {
285+
$azuread_not_enabled_count = $azuread_not_enabled_list.Count
286+
if ($azuread_not_enabled_count -ne 0) {
287+
Write-Error "$azuread_not_enabled_count users in Azure AD are blocked from sign-in."
288+
}
289+
if ($dbu_not_queried_count -ne 0 -or $dbu_duplicate_count -ne 0 -or $dbu_not_matched_count -ne 0 -or $dbu_match_ambiguous_count -ne 0 -or $dbu_query_failed_count -ne 0 -or $azuread_not_enabled_count) {
284290
Write-Output "You will need to resolve those issues before access of all existing users can be reviewed."
285291
}
286292
$azuread_match_count = $azuread_match_id_list.Count
@@ -291,7 +297,7 @@ The first time your organization uses these cmdlets for this scenario, you need
291297

292298
For example, someone's email address might have been changed in Azure AD without their corresponding `mail` property being updated in the application's data source. Or, the user might have already left the organization but is still in the application's data source. Or there might be a vendor or super-admin account in the application's data source that does not correspond to any specific person in Azure AD.
293299

294-
1. If there were users who couldn't be located in Azure AD, but you want to have their access reviewed or their attributes updated in the database, you need to create Azure AD users for them. You can create users in bulk by using either:
300+
1. If there were users who couldn't be located in Azure AD, or weren't active and able to sign in, but you want to have their access reviewed or their attributes updated in the database, you need to update or create Azure AD users for them. You can create users in bulk by using either:
295301

296302
- A CSV file, as described in [Bulk create users in the Azure AD portal](../enterprise-users/users-bulk-add.md)
297303
- The [New-MgUser](/powershell/module/microsoft.graph.users/new-mguser?view=graph-powershell-1.0#examples) cmdlet
@@ -306,6 +312,7 @@ The first time your organization uses these cmdlets for this scenario, you need
306312
$dbu_match_ambiguous_list = @()
307313
$dbu_query_failed_list = @()
308314
$azuread_match_id_list = @()
315+
$azuread_not_enabled_list = @()
309316
$dbu_values = @()
310317
$dbu_duplicate_list = @()
311318
@@ -316,10 +323,11 @@ The first time your organization uses these cmdlets for this scenario, you need
316323
if ($dbu_values -contains $escval) { $dbu_duplicate_list += $dbu; continue } else { $dbu_values += $escval }
317324
$filter = $azuread_match_attr_name + " eq '" + $escval + "'"
318325
try {
319-
$ul = @(Get-MgUser -Filter $filter -All -ErrorAction Stop)
326+
$ul = @(Get-MgUser -Filter $filter -All -Property Id,accountEnabled -ErrorAction Stop)
320327
if ($ul.length -eq 0) { $dbu_not_matched_list += $dbu; } elseif ($ul.length -gt 1) {$dbu_match_ambiguous_list += $dbu } else {
321328
$id = $ul[0].id;
322329
$azuread_match_id_list += $id;
330+
if ($ul[0].accountEnabled -eq $false) {$azuread_not_enabled_list += $id }
323331
}
324332
} catch { $dbu_query_failed_list += $dbu }
325333
} else { $dbu_not_queried_list += $dbu }
@@ -345,7 +353,11 @@ The first time your organization uses these cmdlets for this scenario, you need
345353
if ($dbu_query_failed_count -ne 0) {
346354
Write-Error "Unable to locate $dbu_query_failed_count records in Azure AD as queries returned errors."
347355
}
348-
if ($dbu_not_queried_count -ne 0 -or $dbu_duplicate_count -ne 0 -or $dbu_not_matched_count -ne 0 -or $dbu_match_ambiguous_count -ne 0 -or $dbu_query_failed_count -ne 0) {
356+
$azuread_not_enabled_count = $azuread_not_enabled_list.Count
357+
if ($azuread_not_enabled_count -ne 0) {
358+
Write-Error "$azuread_not_enabled_count users in Azure AD are blocked from sign-in."
359+
}
360+
if ($dbu_not_queried_count -ne 0 -or $dbu_duplicate_count -ne 0 -or $dbu_not_matched_count -ne 0 -or $dbu_match_ambiguous_count -ne 0 -or $dbu_query_failed_count -ne 0 -or $azuread_not_enabled_count -ne 0) {
349361
Write-Output "You will need to resolve those issues before access of all existing users can be reviewed."
350362
}
351363
$azuread_match_count = $azuread_match_id_list.Count
@@ -479,7 +491,7 @@ When an application role assignment is created in Azure AD for a user to an appl
479491

480492
If you don't see users being provisioned, check the [troubleshooting guide for no users being provisioned](../app-provisioning/application-provisioning-config-problem-no-users-provisioned.md). If you see an error in the provisioning status and are provisioning to an on-premises application, check the [troubleshooting guide for on-premises application provisioning](../app-provisioning/on-premises-ecma-troubleshoot.md).
481493

482-
1. Check the [provisioning log](../reports-monitoring/concept-provisioning-logs.md). Filter the log to the status **Failure**. If there are failures with an ErrorCode of **DuplicateTargetEntries**, this indicates an ambiguity in your provisioning matching rules, and you will need to update the Azure AD users or the mappings that are used for matching to ensure each Azure AD user matches one application user.
494+
1. Check the [provisioning log](../reports-monitoring/concept-provisioning-logs.md). Filter the log to the status **Failure**. If there are failures with an ErrorCode of **DuplicateTargetEntries**, this indicates an ambiguity in your provisioning matching rules, and you will need to update the Azure AD users or the mappings that are used for matching to ensure each Azure AD user matches one application user. Then filter the log to the action **Create** and status **Skipped**. If users were skipped with the SkipReason code of **NotEffectivelyEntitled**, this may indicate that the user accounts in Azure AD were not matched because the user account status was **Disabled**.
483495

484496
After the Azure AD provisioning service has matched the users based on the application role assignments you've created, subsequent changes will be sent to the application.
485497

0 commit comments

Comments
 (0)