Skip to content

feat(ad): add explicit LDAP protection opt-outs - #2846

Open
soulemike wants to merge 4 commits into
maester365:mainfrom
soulemike:feat/ad-unencrypted-connection
Open

soulemike wants to merge 4 commits into
maester365:mainfrom
soulemike:feat/ad-unencrypted-connection

Conversation

@soulemike

@soulemike soulemike commented Nov 20, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Adds explicit LDAP encryption/signing opt-outs and separately acknowledged plaintext Basic binds, with clear warnings, fail-closed checks, and settings preserved across reconnects.

Validation

6,915 tests with no failures; module and website builds passed; 59 Windows tests and all 8 Azure lab cases passed. Temporary lab policy was restored.

  • Explicit unsigned/unsealed Negotiate, Kerberos, and NTLM connections worked, including subsequent domain, GPO, and DACL reads.
  • Plaintext Basic worked only with the additional acknowledgement.
  • Missing acknowledgements and policy-overridden signing were correctly rejected.
  • The encrypted LDAPS control passed. Unit tests confirmed unchanged encrypted defaults and no plaintext fallback from Auto, LDAPS, or StartTLS.
  • The full suite completed 6,915 tests with no failures.
  • This is not exhaustive regression certification: Linux and child/separate-forest live testing were not performed, and Auto/StartTLS were not rerun live against the final expanded change.

Limitations

Explicit SASL opt-outs require provider and policy support. Branch has not been rebased onto latest upstream main.

Summary by CodeRabbit

  • New Features
    • Active Directory connections now support an explicit unencrypted LDAP mode; encrypted connections remain the default.
    • Separate acknowledgements are required to disable encryption, disable signing, or use Basic authentication with a plaintext password. Plaintext-password connections also require an explicitly specified server.
    • Connection summaries and warnings identify disabled protections and associated risks. Connections fail if required signing or sealing settings cannot be applied.
    • Protection settings are preserved when connections are reused and reflected in relevant cache behavior.
  • Documentation
    • Added guidance on LDAP protection, opt-in requirements, risks, and troubleshooting, including recommendations to limit unencrypted connections to test labs.

@soulemike
soulemike requested review from a team as code owners November 20, 2026 19:49
@github-actions

Copy link
Copy Markdown
Contributor

This pull request changes files that a website explainer describes:

  • How Maester works (website/public/explainers/how-it-works/) describes powershell/public/connect/Connect-Maester.ps1

If the change alters what the explainer shows (a gate, a reason code, a command, a count), update its composition and its chapters in website/src/data/explainers.json. If it doesn't, no action is needed.

@coderabbitai

coderabbitai Bot commented Nov 20, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

Active Directory connections now support an explicit unencrypted LDAP mode with separate acknowledgements for unencrypted transport, unsigned SASL, and Basic-auth plaintext passwords. Connection creation enforces the selected options. Active Directory reads preserve them in protocol evidence and cache keys.

Changes: LDAP connection protection

Layer / File(s) Summary
Expose and select connection options
powershell/internal/services/ad/Connect-MtAdTarget.ps1, powershell/internal/services/ad/Get-MtAdSupportedAuthMatrix.ps1, powershell/public/connect/Connect-Maester.ps1, powershell/tests/functions/ActiveDirectoryProtocol.Tests.ps1, website/docs/advanced/active-directory.md, website/docs/connect-maester/ad-connection-troubleshooting.md
Connection entry points accept None and the protection acknowledgements. Validation restricts the options to supported combinations, while existing automatic TLS attempts remain unchanged. Public examples, compatibility profiles, documentation, and protocol tests cover the options and defaults.
Enforce LDAP protection settings
powershell/internal/services/ad/protocol/New-MtLdapConnection.ps1, powershell/internal/services/ad/protocol/Write-MtLdapProtectionWarning.ps1, powershell/tests/functions/ActiveDirectoryLdapProtection.Tests.ps1
LDAP connection creation validates the selected options and warns when TLS is disabled. For unencrypted non-Basic connections, it checks sealing and signing settings before binding and verifies them after binding. Tests cover rejected combinations and provider or policy failures.
Preserve options across reads and re-probes
powershell/internal/services/ad/protocol/Get-MtAdLdapProtectionCacheSuffix.ps1, powershell/internal/services/ad/protocol/New-MtAdProtocolConnection.ps1, powershell/public/services/ad/Get-MtADDacls.ps1, powershell/public/services/ad/Get-MtADDomainState.ps1, powershell/public/services/ad/Get-MtADGpoState.ps1, powershell/tests/functions/ActiveDirectoryLdapProtection.Tests.ps1
Protocol evidence records the requested server and protection settings. Domain, GPO, and DACL reads pass those settings to connection creation and include the protection mode in cache keys. Re-created connections use the recorded server and options.

Estimated code review effort: 4 (Complex) | ~45 minutes

Change: Feature

Sequence Diagram(s)

sequenceDiagram
  participant ConnectMaester as Connect-Maester
  participant ConnectTarget as Connect-MtAdTarget
  participant ProtocolConnection as New-MtAdProtocolConnection
  participant LdapConnection as New-MtLdapConnection
  participant DomainState as Get-MtADDomainState
  ConnectMaester->>ConnectTarget: Pass selected TLS and protection options
  ConnectTarget->>LdapConnection: Create LDAP connection with selected options
  DomainState->>ProtocolConnection: Recreate connection from protocol evidence
  ProtocolConnection->>LdapConnection: Pass recorded protection options and server
Loading

Suggested reviewers: merill, snozz-al, samerde

Merge Risk: Minimal · up to 93813

This change adds explicit, opt-in unencrypted LDAP modes that require acknowledgements and fail closed. Encrypted defaults are preserved and tests cover the new paths. No actionable merge-blocking risk was found.

Pre-merge checks: Passed 3 · Inconclusive 1

Failed Failed checks: 1 inconclusive

Check name Status Explanation Resolution
Description check Inconclusive The description covers the summary, validation results, and limitations. It does not follow the repository template. It omits the code freeze notice (which is informational), the linked issue ("Closes… Use the repository's pull request template. Fill in the "Closes #" line with the related issue number, or state that no issue exists. Keep the "## 📑 Description" and "## ✅ Checks" headings, and tick the checklist items that apply (code styl…
Passed Passed checks: 3 passed

Check name Status Explanation
Title check Passed The title "feat(ad): add explicit LDAP protection opt-outs" names the main change. The PR adds explicit opt-outs for LDAP encryption and SASL signing, plus a separately acknowledged plaintext Basic bi…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Title check

Explanation

The title "feat(ad): add explicit LDAP protection opt-outs" names the main change. The PR adds explicit opt-outs for LDAP encryption and SASL signing, plus a separately acknowledged plaintext Basic bind option. The title is specific, short, and follows a conventional commit style.

Full details: Description check

Explanation

The description covers the summary, validation results, and limitations. It does not follow the repository template. It omits the code freeze notice (which is informational), the linked issue ("Closes # <!-- Issue # here -->" is left unfilled), and the checklist, which is unticked and not updated. The Additional Information section is also absent. The author's content is detailed and useful, but the template structure is not followed and the issue reference is missing.

Resolution

Use the repository's pull request template. Fill in the "Closes #" line with the related issue number, or state that no issue exists. Keep the "## 📑 Description" and "## ✅ Checks" headings, and tick the checklist items that apply (code style, docs updated, and the pester.ps1 run). Move the validation details and limitations under "## ℹ️ Additional Information".

Finishing Touches

Generate unit tests (beta)

  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

Recent review info

Run configuration

Commits

Reviewing files that changed from the base of the PR and between a14c6de and 9381389.

Files selected for processing: 5

  • powershell/internal/services/ad/protocol/Get-MtAdLdapProtectionCacheSuffix.ps1
  • powershell/internal/services/ad/protocol/Write-MtLdapProtectionWarning.ps1
  • powershell/public/connect/Connect-Maester.ps1
  • powershell/tests/functions/ActiveDirectoryLdapProtection.Tests.ps1
  • powershell/tests/functions/ActiveDirectoryProtocol.Tests.ps1
Files skipped from review as they are similar to previous changes: 4

  • powershell/internal/services/ad/protocol/Get-MtAdLdapProtectionCacheSuffix.ps1
  • powershell/internal/services/ad/protocol/Write-MtLdapProtectionWarning.ps1
  • powershell/public/connect/Connect-Maester.ps1
  • powershell/tests/functions/ActiveDirectoryLdapProtection.Tests.ps1

Included review availability: This review used your included allowance. Your plan provides up to 4 included reviews per hour; 2 remain after this review.

@codacy-production

Copy link
Copy Markdown

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.

@soulemike soulemike added the product: ad On-premises Active Directory label Nov 20, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

product: ad On-premises Active Directory

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants