Skip to content

Commit

Permalink
Remove Schema Admin check
Browse files Browse the repository at this point in the history
  • Loading branch information
bill-long committed Aug 6, 2021
1 parent 58c2913 commit 55faa8c
Showing 1 changed file with 11 additions and 13 deletions.
24 changes: 11 additions & 13 deletions Security/src/Test-CVE-2021-34470.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -65,20 +65,18 @@ if ($ApplyFix) {
$storageGroupSchemaEntry.Properties["possSuperiors"] | Out-File $OutputFile -Append
}

$isSchemaAdmin = $null -ne (whoami /groups | Select-String "\\Schema Admins\s+")
if (-not $isSchemaAdmin) {
Write-Warning "This user is not in Schema Admins. Cannot apply fix."
return
}

Write-Host "Attempting to apply fix..."
try {
Write-Host "Attempting to apply fix..."

$rootDSE = [ADSI]("LDAP://$($schemaMaster)/RootDSE")
[void]$rootDSE.Properties["schemaUpgradeInProgress"].Add(1)
$rootDSE.CommitChanges()
$rootDSE = [ADSI]("LDAP://$($schemaMaster)/RootDSE")
[void]$rootDSE.Properties["schemaUpgradeInProgress"].Add(1)
$rootDSE.CommitChanges()

$storageGroupSchemaEntry.Properties["possSuperiors"].Clear()
$storageGroupSchemaEntry.CommitChanges()
$storageGroupSchemaEntry.Properties["possSuperiors"].Clear()
$storageGroupSchemaEntry.CommitChanges()

Write-Host "Fix was applied successfully."
Write-Host "Fix was applied successfully."
} catch {
Write-Warning "Failed to apply fix. Please ensure you have Schema Admin rights. Error was: `n$_"
}
}

0 comments on commit 55faa8c

Please sign in to comment.