feat(connection-context): auto-detect forest/credential with interactive approval prompt#61
Merged
Merged
Conversation
…ompt - Add Resolve-LS2ConnectionContext (Explicit, ExplicitCredential, DomainUser, DomainComputer, PromptedAll; 3-attempt retry on bad bind) - Add Test-IsInteractiveSession helper; wire context resolution into Invoke-Locksmith2 - Show Forest/User/Computer/Method approval prompt in interactive sessions before scan starts - Fix New-AuthenticatedDirectoryEntry: null guard falls back to unauthenticated DirectoryEntry when no credential - Fix Get-RootDSE: remove Read-Host retry loop, fail-fast with WriteError; add \ flag to skip credential prompts on DomainUser/DomainComputer paths
…ential prompts - Add TCP port 389 pre-flight check to Get-RootDSE (5s timeout) to prevent indefinite hang on unreachable hosts - Replace Get-Credential GUI dialog with Read-Host -AsSecureString in Resolve-LS2ConnectionContext (PS 5.1-safe, always in-terminal) - Update PromptedAll and retry tests to mock Read-Host with ParameterFilter instead of Get-Credential
…o guide input format
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds
Resolve-LS2ConnectionContext— a prioritized detection strategy that automatically determines the correct forest and credential before a scan starts, eliminating the need for manual-Forestand-Credentialparameters in most environments.Changes
New functions
Private/Utility/Resolve-LS2ConnectionContext.ps1— detection decision tree (Explicit, ExplicitCredential, DomainUser, DomainComputer, PromptedAll; 3-attempt retry on failed RootDSE bind)Private/Test/Test-IsInteractiveSession.ps1— detects interactive vs non-interactive sessionModified
Public/Invoke-Locksmith2.ps1— callsResolve-LS2ConnectionContextbefore scan; shows Forest/User/Computer/Method approval prompt in interactive sessionsPrivate/Get/Get-RootDSE.ps1— adds TCP port 389 pre-flight check (5s timeout) to prevent indefinite hang on unreachable hosts; removes legacy Read-Host retry loopPrivate/New/New-AuthenticatedDirectoryEntry.ps1— null guard falls back to unauthenticatedDirectoryEntrywhen no credential (enables DomainUser/DomainComputer paths)Private/Initialize/Initialize-LS2Scan.ps1,Initialize-DomainStore.ps1,Initialize-AdcsObjectStore.ps1—$script:CredentialResolvedflag skips credential prompts when context is already resolvedPrivate/Utility/Resolve-LS2ConnectionContext.ps1— replacesGet-CredentialGUI dialog withRead-Host -AsSecureStringfor PS 5.1-safe in-terminal credential collectionTests
Tests/Private/Utility/Resolve-LS2ConnectionContext.Tests.ps1— 17 tests, all GREENTests/Private/Get/Get-RootDSE.Tests.ps1— 5 tests, all GREENTests/Private/Test/Test-IsInteractiveSession.Tests.ps1— 6 tests, all GREENDetection methods
Explicit-Forestand-CredentialsuppliedExplicitCredential-Credentialonly; forest derived from usernameDomainUserDomainComputerPromptedAll