From 5e9be0a0b392cc8e5d3587b9f4bb56a2f6551feb Mon Sep 17 00:00:00 2001 From: Mathieu Moran Date: Sat, 24 Oct 2026 13:49:08 -0400 Subject: [PATCH] Anchor the delegation in AdminSDHolder; document the mechanism BUILTIN\Administrators is itself a protected group, so adding Serveurs-Admins to it made m.legault transitively protected too: SDProp then wiped both ACEs and reset adminCount. doctor caught it. The durable fix is the one that works in a real domain: the ACE lives in AdminSDHolder, which SDProp copies onto protected objects every hour, so it is re-applied rather than deleted. The adminCount workaround is gone. Lore gains a 2021 note explaining exactly this, in the voice of the instructor who hit it: the delegation kept vanishing, the vendor explained AdminSDHolder, the right was moved there and stopped disappearing. --- content/lib/cmd_doctor.sh | 8 ++++++-- .../_archives/2021/note-adminsdholder.txt | 11 +++++++++++ content/web/seed/public/_archives/README.txt | 1 + content/windows/roles/dc01-post.ps1 | 18 +++++++++--------- 4 files changed, 27 insertions(+), 11 deletions(-) create mode 100644 content/web/seed/public/_archives/2021/note-adminsdholder.txt diff --git a/content/lib/cmd_doctor.sh b/content/lib/cmd_doctor.sh index 0de1c86..e1b2a82 100644 --- a/content/lib/cmd_doctor.sh +++ b/content/lib/cmd_doctor.sh @@ -115,6 +115,7 @@ $plainAcl = Get-Acl ("AD:\" + (Get-ADUser m.legault).DistinguishedName) "ace_plain=" + @($plainAcl.Access | Where-Object { $_.IdentityReference.Value -like "*svc_backup*" }).Count "plain_enabled=" + (Get-ADUser m.legault).Enabled "dcadmin=" + ((Get-ADGroupMember "S-1-5-32-544").Name -contains "Serveurs-Admins") +"sdh=" + @((dsacls.exe ("CN=AdminSDHolder,CN=System," + (Get-ADDomain).DistinguishedName) | Select-String "svc_backup")).Count "admincount=" + (Get-ADUser t.smith -Properties adminCount).adminCount "spn=" + @((Get-ADUser svc_backup -Properties ServicePrincipalNames).ServicePrincipalNames).Count "preauth=" + (Get-ADUser j.contractor -Properties DoesNotRequirePreAuth).DoesNotRequirePreAuth @@ -125,6 +126,7 @@ $plainAcl = Get-Acl ("AD:\" + (Get-ADUser m.legault).DistinguishedName) "kali_res=" + @((Get-DhcpServerv4Reservation -ScopeId 10.10.10.0 -EA SilentlyContinue) | Where-Object { $_.IPAddress -eq "10.10.10.101" }).Count ' 2>/dev/null) || { _d_warn "cannot query DC01 for lab state"; return; } + local sdh_ok=0 while IFS='=' read -r key value; do value=${value//$'\r'/} case $key in @@ -136,8 +138,10 @@ $plainAcl = Get-Acl ("AD:\" + (Get-ADUser m.legault).DistinguishedName) else _d_fail "m.legault is disabled — the path is dead"; fi ;; dcadmin) if [[ $value == True ]]; then _d_ok "Serveurs-Admins is DC local admin" else _d_fail "Serveurs-Admins is not in BUILTIN\Administrators"; fi ;; - admincount) if [[ $value == 0 ]]; then _d_ok "t.smith outside SDProp (adminCount=0)" - else _d_warn "adminCount=$value: SDProp will delete the ACE within the hour"; fi ;; + sdh) if [[ $value -ge 1 ]]; then _d_ok "AdminSDHolder carries the delegation (SDProp-proof)"; sdh_ok=1 + else _d_warn "delegation not anchored in AdminSDHolder"; fi ;; + admincount) if (( sdh_ok )) || [[ $value == 0 ]]; then _d_ok "protected objects cannot strip the ACE" + else _d_warn "adminCount=$value and no AdminSDHolder anchor"; fi ;; spn) [[ $value -ge 1 ]] && _d_ok "service account: SPN present" || _d_fail "svc_backup has no SPN" ;; preauth) [[ $value == True ]] && _d_ok "pre-auth disabled on j.contractor" || _d_fail "j.contractor still requires pre-auth" ;; minage) [[ $value == 0 ]] && _d_ok "minimum password age: 0" || _d_fail "minimum password age is $value h" ;; diff --git a/content/web/seed/public/_archives/2021/note-adminsdholder.txt b/content/web/seed/public/_archives/2021/note-adminsdholder.txt new file mode 100644 index 0000000..48ce908 --- /dev/null +++ b/content/web/seed/public/_archives/2021/note-adminsdholder.txt @@ -0,0 +1,11 @@ +Note - 2021-02-03 +----------------- +La delegation de sauvegarde sur les comptes d'administrateurs +disparaissait regulierement, sans explication. + +Le vendeur a explique que Windows remet les permissions des comptes +proteges a jour toutes les heures, a partir d'un objet modele appele +AdminSDHolder. + +Solution : on a mis le droit directement dans AdminSDHolder. +Depuis, il revient tout seul. diff --git a/content/web/seed/public/_archives/README.txt b/content/web/seed/public/_archives/README.txt index 777d1b6..cb0e330 100644 --- a/content/web/seed/public/_archives/README.txt +++ b/content/web/seed/public/_archives/README.txt @@ -10,3 +10,4 @@ Les dates sont celles des fichiers d'origine. 2011/ deploiement de l'agent sur les postes 2016/ administration du controleur de domaine 2019/ arrivee de t.smith +2021/ delegation ancree dans AdminSDHolder diff --git a/content/windows/roles/dc01-post.ps1 b/content/windows/roles/dc01-post.ps1 index 8fc8d4a..dc6eb5c 100644 --- a/content/windows/roles/dc01-post.ps1 +++ b/content/windows/roles/dc01-post.ps1 @@ -99,15 +99,15 @@ try { Write-LabLog 'dc01: svc_backup already has an ACE on t.smith' } - # t.smith is a Domain Admin, therefore a "protected" object: SDProp resets - # his security descriptor every hour and deletes any ACE not present in - # AdminSDHolder. Clearing adminCount takes him out of SDProp's scope while - # leaving his Domain Admins membership intact. - try { - Set-ADObject -Identity 't.smith' -Replace @{ adminCount = 0 } -ErrorAction Stop - Write-LabLog 'dc01: t.smith excluded from SDProp (adminCount=0)' - } catch { - Write-LabLog "dc01: could not clear adminCount ($($_.Exception.Message))" + # t.smith is a Domain Admin and m.legault is in BUILTIN\Administrators, so + # both are *protected* objects: SDProp rewrites their security descriptor + # from AdminSDHolder every hour and deletes any ACE that only lives on the + # object. Anchoring the same ACE in AdminSDHolder is what makes it stick — + # SDProp then re-applies it instead of removing it. + $adminSdHolder = "CN=AdminSDHolder,CN=System,$base" + if (-not (dsacls.exe $adminSdHolder | Select-String 'svc_backup')) { + $null = dsacls.exe $adminSdHolder /G '@@NETBIOS@@\svc_backup:GA' + Write-LabLog 'dc01: delegation anchored in AdminSDHolder' } # Realistic delegation: the service account manages a plain user who is a