Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add warnings for enable/disable and password reset on AD synced users #985

Merged
merged 3 commits into from
Jul 15, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Adds warning if user is AD synced
chase-vgo authored Jul 12, 2024
commit 6819ffcec62ea2b1cda21ac20e22426346518793
10 changes: 8 additions & 2 deletions Modules/CIPPCore/Public/Set-CIPPSignInState.ps1
Original file line number Diff line number Diff line change
@@ -13,13 +13,19 @@ function Set-CIPPSignInState {
accountEnabled = [bool]$AccountEnabled
}
$body = ConvertTo-Json -InputObject $body -Compress -Depth 5
$UserDetails = New-GraphGetRequest -uri "https://graph.microsoft.com/v1.0/users/$($UserId)?`$select=onPremisesSyncEnabled" -noPagination $true -tenantid $TenantFilter -verbose
$null = New-GraphPostRequest -uri "https://graph.microsoft.com/v1.0/users/$($UserId)" -tenantid $TenantFilter -type PATCH -body $body -verbose
Write-LogMessage -user $ExecutingUser -API $APIName -message "Set account enabled state to $AccountEnabled for $UserId" -Sev 'Info' -tenant $TenantFilter
return "Set account enabled state to $AccountEnabled for $UserId"

if($UserDetails.onPremisesSyncEnabled -eq $true){
return "WARNING: User is AD Sync enabled. Please enable/disable in AD."
}else{
return "Set account enabled state to $AccountEnabled for $UserId"
}

} catch {
$ErrorMessage = Get-CippException -Exception $_
Write-LogMessage -user $ExecutingUser -API $APIName -message "Could not disable sign in for $UserId. Error: $($ErrorMessage.NormalizedError)" -Sev 'Error' -tenant $TenantFilter -LogData $ErrorMessage
return "Could not disable $UserId. Error: $($ErrorMessage.NormalizedError)"
}
}