AllowedToAct
Summary
Description
Identification
PowerShell
function Find-AllowedToAct {
[CmdletBinding()]
param ([string]$Target = $null,[string]$SearchBase = $null,[string]$OutputPath = "AllowedToAct.csv")
Import-Module ActiveDirectory
Write-Host "Gathering Active Directory objects with resource-based constrained delegation settings..."
$adObjectParams = @{
Filter = "*"
Properties = "msDS-AllowedToActOnBehalfOfOtherIdentity"
ErrorAction = "Stop"}
if ($SearchBase) {$adObjectParams.Add("SearchBase", $SearchBase);Write-Host "Searching for objects within '$SearchBase'."} else {$adObjectParams.Add("SearchBase", (Get-ADRootDSE).DefaultNamingContext);Write-Host "Searching for all objects in the domain."}
$results = @();$objectsToScan = @()
try {if ($Target) {
Write-Host "Searching for delegation properties on specific object: '$Target'."
$specificObject = Get-ADComputer -Identity $Target -Properties "msDS-AllowedToActOnBehalfOfOtherIdentity" -ErrorAction Stop
if ($specificObject) { $objectsToScan += $specificObject} else {Write-Output "Object '$Target' not found.";return}
} else {$objectsToScan = Get-ADComputer @adObjectParams}
$objectsToScan = $objectsToScan | Where-Object { $_.'msDS-AllowedToActOnBehalfOfOtherIdentity' }
if (-not $objectsToScan) { Write-Output "No objects found with 'msDS-AllowedToActOnBehalfOfOtherIdentity' configured.";return}
Write-Host "Processing $($objectsToScan.Count) object(s)..."
foreach ($object in $objectsToScan) {
$secDesc = $object.'msDS-AllowedToActOnBehalfOfOtherIdentity'
if ($secDesc -is [System.DirectoryServices.ActiveDirectorySecurity]) {
foreach ($ace in $secDesc.GetAccessRules($true, $true, [System.Security.Principal.SecurityIdentifier])) {
$sid = $ace.IdentityReference;$objectName = "Unknown" # Default value
try {
$adObject = [ADSI]("LDAP://<SID=$($sid.Value)>")
if ($adObject.Properties["name"].Count -gt 0) {$objectName = $adObject.Properties["name"][0]} else {$objectName = "SID: $($sid.Value)" }}
catch {Write-Warning "Could not resolve SID '$($sid.Value)' for object '$($object.Name)': $($_.Exception.Message)";$objectName = "SID: $($sid.Value) (Resolution Failed)";}
$results += [PSCustomObject]@{
To = $object.Name
CanDelegate = $objectName}}} else {Write-Warning "The 'msDS-AllowedToActOnBehalfOfOtherIdentity' attribute for object '$($object.Name)' is not a valid ActiveDirectorySecurity object. Type: $($secDesc.GetType().FullName)"}}}
catch { Write-Error "Failed to retrieve Active Directory objects or process delegation settings: $($_.Exception.Message)";return; }
if ($results.Count -gt 0) {
Write-Host "Found $($results.Count) resource-based constrained delegation entry/entries."
try {$results | Sort-Object -Unique To, CanDelegate | Export-Csv -Path $OutputPath -NoTypeInformation -Encoding UTF8;Write-Output "Results exported successfully to '$OutputPath'"}catch {Write-Error "Failed to export results to CSV file '$OutputPath': $($_.Exception.Message)"}} else {Write-Output "No resource-based constrained delegation entries found."}}Exploitation
Windows



Linux


Mitigation
Detection
Event ID
Description
Fields/Attributes
References
References
Last updated
Was this helpful?