-
Notifications
You must be signed in to change notification settings - Fork 134
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
xGroup: Refactored Principal Resolution Functions for Enhanced Virtual Account Support #764
Conversation
Support - Enhanced Test-IsLocalMachine to recognize 'IIS APPPOOL' and 'NT VIRTUAL MACHINE' as local machine scopes, improving virtual account type coverage. - Updated Split-MemberName to preserve original scope, allowing local accounts that do not use the computer name to be resolved. - Extended Find-Principal with a new Scope parameter, enabling searches additional local machine scopes. - Augmented Find-Principal to handle a predefined list of NT account scopes ('NT Authority', 'NT Service', 'IIS APPPOOL', 'NT Virtual Machine'), utilizing System.Security.Principal.NTAccount for SID resolution. This enhancement focuses on local virtual account identification. - Implemented new integration tests for ConvertTo-Principal to verify local, virtual account resolution. - Introduced Get-ScopeFromDistinguishedName to accurately parse scope from distinguished names, addressing issues with multiple domain components and escaped commas. - Added unit tests for Get-ScopeFromDistinguishedName, ensuring functional correctness. - Adjusted outside domain test to expect 'domain.com' instead of 'domain'.
mock call count.
Test-Path mock to account for the short-circuiting of the if conditions on line 449 of DSC_xDSCWebService.psm1 preventing the third condition from being evaluated.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great stuff @kenny-scelfo - thanks for submitting this. Just some minor bits and will merge.
Reviewed 5 of 5 files at r1, all commit messages.
Reviewable status: all files reviewed, 8 unresolved discussions (waiting on @kenny-scelfo)
CHANGELOG.md
line 9 at r1 (raw file):
- xGroup - Fixed a bug where the resource would fail if any of the group members were
Do these fix xGroupResource Throws Exceptions when Using Multiple Local Virtual Account Types · Issue #763 · dsccommunity/xPSDesiredStateConfiguration (github.com)? If so, can we referrence the issue with - Fixes [Issue #763](https://github.com/dsccommunity/xPSDesiredStateConfiguration/issues/763)
?
source/DSCResources/DSC_xGroupResource/DSC_xGroupResource.psm1
line 2258 at r1 (raw file):
Specifies the distinguished name string from which the scope is to be extracted. .EXAMPLE Get-ScopeFromDistinguishedName -DistinguishedName "CN=John Doe,OU=Users,DC=example,DC=com"
Can we include an example with an unescaped string shows (e.g., like in the unit tests - this helps explain why the function is implemented as a loop over the char array rather than a -split).
source/DSCResources/DSC_xGroupResource/DSC_xGroupResource.psm1
line 2270 at r1 (raw file):
$domainComponents = @() $escaped = $false $currentComponent = ""
Can we change to single quotes?
source/DSCResources/DSC_xGroupResource/DSC_xGroupResource.psm1
line 2430 at r1 (raw file):
[Parameter(Mandatory = $true)] [string]
Can we use [System.String]
?
source/DSCResources/DSC_xGroupResource/DSC_xGroupResource.psm1
line 2447 at r1 (raw file):
{ $fullIdentityValue = "$Scope\$IdentityValue" $ntAccount = New-Object System.Security.Principal.NTAccount($fullIdentityValue)
Can you add the parameter name here? e.g. New-Object -TypeName ...
?
source/DSCResources/DSC_xGroupResource/DSC_xGroupResource.psm1
line 2450 at r1 (raw file):
$sid = $ntAccount.Translate([System.Security.Principal.SecurityIdentifier]).Value return [System.DirectoryServices.AccountManagement.Principal]::FindByIdentity($PrincipalContext, [System.DirectoryServices.AccountManagement.IdentityType]::Sid, $sid) }
Can you add a blank line after this one?
tests/Unit/DSC_xGroupResource.Tests.ps1
line 321 at r1 (raw file):
Context 'xGroupResource\Get-ScopeFromDistinguishedName' {
Nit: can you remove this blank line?
tests/Unit/DSC_xGroupResource.Tests.ps1
line 322 at r1 (raw file):
Context 'xGroupResource\Get-ScopeFromDistinguishedName' { It 'when given a valid distinguished name it returns the correct domain name' {
Nit: to help make the test output more readable, can you begin each It
description with a "Should". E.g., Should return the correct domain name when given a valid distinguished name
- and throughout the remaining tests.
review process
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the quick review.
Reviewable status: 2 of 5 files reviewed, 6 unresolved discussions (waiting on @PlagueHO)
CHANGELOG.md
line 9 at r1 (raw file):
Previously, PlagueHO (Daniel Scott-Raynsford) wrote…
Do these fix xGroupResource Throws Exceptions when Using Multiple Local Virtual Account Types · Issue #763 · dsccommunity/xPSDesiredStateConfiguration (github.com)? If so, can we referrence the issue with
- Fixes [Issue #763](https://github.com/dsccommunity/xPSDesiredStateConfiguration/issues/763)
?
Done.
source/DSCResources/DSC_xGroupResource/DSC_xGroupResource.psm1
line 2258 at r1 (raw file):
Previously, PlagueHO (Daniel Scott-Raynsford) wrote…
Can we include an example with an unescaped string shows (e.g., like in the unit tests - this helps explain why the function is implemented as a loop over the char array rather than a -split).
Done.
source/DSCResources/DSC_xGroupResource/DSC_xGroupResource.psm1
line 2270 at r1 (raw file):
Previously, PlagueHO (Daniel Scott-Raynsford) wrote…
Can we change to single quotes?
Done.
source/DSCResources/DSC_xGroupResource/DSC_xGroupResource.psm1
line 2430 at r1 (raw file):
Previously, PlagueHO (Daniel Scott-Raynsford) wrote…
Can we use
[System.String]
?
Done.
source/DSCResources/DSC_xGroupResource/DSC_xGroupResource.psm1
line 2447 at r1 (raw file):
Previously, PlagueHO (Daniel Scott-Raynsford) wrote…
Can you add the parameter name here? e.g.
New-Object -TypeName ...
?
Done.
source/DSCResources/DSC_xGroupResource/DSC_xGroupResource.psm1
line 2450 at r1 (raw file):
Previously, PlagueHO (Daniel Scott-Raynsford) wrote…
Can you add a blank line after this one?
Done.
Looks like this also fixes #350 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wow - yes, it does! From 2017. I have updated the PR description to close this issue as well. Thanks for all the work!
Reviewed 3 of 3 files at r2, all commit messages.
Reviewable status: complete! all files reviewed, all discussions resolved (waiting on @kenny-scelfo)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewable status: complete! all files reviewed, all discussions resolved
Pull Request (PR) description
This Pull Request (PR) fixes the following issues
Task list
file CHANGELOG.md. Entry should say what was changed and how that
affects users (if applicable), and reference the issue being resolved
(if applicable).
and comment-based help.
This change is