@@ -7679,22 +7679,29 @@ System.Security.AccessControl.AuthorizationRule
7679
7679
)
7680
7680
7681
7681
Begin {
7682
- $PrincipalSearcherArguments = @{
7683
- 'Identity' = $PrincipalIdentity
7684
- 'Properties' = 'distinguishedname,objectsid'
7682
+ if ($PrincipalIdentity -notmatch '^S-1-.*') {
7683
+ $PrincipalSearcherArguments = @{
7684
+ 'Identity' = $PrincipalIdentity
7685
+ 'Properties' = 'distinguishedname,objectsid'
7686
+ }
7687
+ if ($PSBoundParameters['PrincipalDomain']) { $PrincipalSearcherArguments['Domain'] = $PrincipalDomain }
7688
+ if ($PSBoundParameters['Server']) { $PrincipalSearcherArguments['Server'] = $Server }
7689
+ if ($PSBoundParameters['SearchScope']) { $PrincipalSearcherArguments['SearchScope'] = $SearchScope }
7690
+ if ($PSBoundParameters['ResultPageSize']) { $PrincipalSearcherArguments['ResultPageSize'] = $ResultPageSize }
7691
+ if ($PSBoundParameters['ServerTimeLimit']) { $PrincipalSearcherArguments['ServerTimeLimit'] = $ServerTimeLimit }
7692
+ if ($PSBoundParameters['Tombstone']) { $PrincipalSearcherArguments['Tombstone'] = $Tombstone }
7693
+ if ($PSBoundParameters['Credential']) { $PrincipalSearcherArguments['Credential'] = $Credential }
7694
+ $Principal = Get-DomainObject @PrincipalSearcherArguments
7695
+ if (-not $Principal) {
7696
+ throw "Unable to resolve principal: $PrincipalIdentity"
7697
+ }
7698
+ elseif($Principal.Count -gt 1) {
7699
+ throw "PrincipalIdentity matches multiple AD objects, but only one is allowed"
7700
+ }
7701
+ $ObjectSid = $Principal.objectsid
7685
7702
}
7686
- if ($PSBoundParameters['PrincipalDomain']) { $PrincipalSearcherArguments['Domain'] = $PrincipalDomain }
7687
- if ($PSBoundParameters['Server']) { $PrincipalSearcherArguments['Server'] = $Server }
7688
- if ($PSBoundParameters['SearchScope']) { $PrincipalSearcherArguments['SearchScope'] = $SearchScope }
7689
- if ($PSBoundParameters['ResultPageSize']) { $PrincipalSearcherArguments['ResultPageSize'] = $ResultPageSize }
7690
- if ($PSBoundParameters['ServerTimeLimit']) { $PrincipalSearcherArguments['ServerTimeLimit'] = $ServerTimeLimit }
7691
- if ($PSBoundParameters['Tombstone']) { $PrincipalSearcherArguments['Tombstone'] = $Tombstone }
7692
- if ($PSBoundParameters['Credential']) { $PrincipalSearcherArguments['Credential'] = $Credential }
7693
- $Principal = Get-DomainObject @PrincipalSearcherArguments
7694
- if (-not $Principal) {
7695
- throw "Unable to resolve principal: $PrincipalIdentity"
7696
- } elseif($Principal.Count -gt 1) {
7697
- throw "PrincipalIdentity matches multiple AD objects, but only one is allowed"
7703
+ else {
7704
+ $ObjectSid = $PrincipalIdentity
7698
7705
}
7699
7706
7700
7707
$ADRight = 0
@@ -7703,7 +7710,7 @@ System.Security.AccessControl.AuthorizationRule
7703
7710
}
7704
7711
$ADRight = [System.DirectoryServices.ActiveDirectoryRights]$ADRight
7705
7712
7706
- $Identity = [System.Security.Principal.IdentityReference] ([System.Security.Principal.SecurityIdentifier]$Principal.objectsid )
7713
+ $Identity = [System.Security.Principal.IdentityReference] ([System.Security.Principal.SecurityIdentifier]$ObjectSid )
7707
7714
}
7708
7715
7709
7716
Process {
0 commit comments