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.
This commit is contained in:
@@ -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
|
"ace_plain=" + @($plainAcl.Access | Where-Object { $_.IdentityReference.Value -like "*svc_backup*" }).Count
|
||||||
"plain_enabled=" + (Get-ADUser m.legault).Enabled
|
"plain_enabled=" + (Get-ADUser m.legault).Enabled
|
||||||
"dcadmin=" + ((Get-ADGroupMember "S-1-5-32-544").Name -contains "Serveurs-Admins")
|
"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
|
"admincount=" + (Get-ADUser t.smith -Properties adminCount).adminCount
|
||||||
"spn=" + @((Get-ADUser svc_backup -Properties ServicePrincipalNames).ServicePrincipalNames).Count
|
"spn=" + @((Get-ADUser svc_backup -Properties ServicePrincipalNames).ServicePrincipalNames).Count
|
||||||
"preauth=" + (Get-ADUser j.contractor -Properties DoesNotRequirePreAuth).DoesNotRequirePreAuth
|
"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
|
"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; }
|
' 2>/dev/null) || { _d_warn "cannot query DC01 for lab state"; return; }
|
||||||
|
|
||||||
|
local sdh_ok=0
|
||||||
while IFS='=' read -r key value; do
|
while IFS='=' read -r key value; do
|
||||||
value=${value//$'\r'/}
|
value=${value//$'\r'/}
|
||||||
case $key in
|
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 ;;
|
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"
|
dcadmin) if [[ $value == True ]]; then _d_ok "Serveurs-Admins is DC local admin"
|
||||||
else _d_fail "Serveurs-Admins is not in BUILTIN\Administrators"; fi ;;
|
else _d_fail "Serveurs-Admins is not in BUILTIN\Administrators"; fi ;;
|
||||||
admincount) if [[ $value == 0 ]]; then _d_ok "t.smith outside SDProp (adminCount=0)"
|
sdh) if [[ $value -ge 1 ]]; then _d_ok "AdminSDHolder carries the delegation (SDProp-proof)"; sdh_ok=1
|
||||||
else _d_warn "adminCount=$value: SDProp will delete the ACE within the hour"; fi ;;
|
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" ;;
|
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" ;;
|
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" ;;
|
minage) [[ $value == 0 ]] && _d_ok "minimum password age: 0" || _d_fail "minimum password age is $value h" ;;
|
||||||
|
|||||||
@@ -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.
|
||||||
@@ -10,3 +10,4 @@ Les dates sont celles des fichiers d'origine.
|
|||||||
2011/ deploiement de l'agent sur les postes
|
2011/ deploiement de l'agent sur les postes
|
||||||
2016/ administration du controleur de domaine
|
2016/ administration du controleur de domaine
|
||||||
2019/ arrivee de t.smith
|
2019/ arrivee de t.smith
|
||||||
|
2021/ delegation ancree dans AdminSDHolder
|
||||||
|
|||||||
@@ -99,15 +99,15 @@ try {
|
|||||||
Write-LabLog 'dc01: svc_backup already has an ACE on t.smith'
|
Write-LabLog 'dc01: svc_backup already has an ACE on t.smith'
|
||||||
}
|
}
|
||||||
|
|
||||||
# t.smith is a Domain Admin, therefore a "protected" object: SDProp resets
|
# t.smith is a Domain Admin and m.legault is in BUILTIN\Administrators, so
|
||||||
# his security descriptor every hour and deletes any ACE not present in
|
# both are *protected* objects: SDProp rewrites their security descriptor
|
||||||
# AdminSDHolder. Clearing adminCount takes him out of SDProp's scope while
|
# from AdminSDHolder every hour and deletes any ACE that only lives on the
|
||||||
# leaving his Domain Admins membership intact.
|
# object. Anchoring the same ACE in AdminSDHolder is what makes it stick —
|
||||||
try {
|
# SDProp then re-applies it instead of removing it.
|
||||||
Set-ADObject -Identity 't.smith' -Replace @{ adminCount = 0 } -ErrorAction Stop
|
$adminSdHolder = "CN=AdminSDHolder,CN=System,$base"
|
||||||
Write-LabLog 'dc01: t.smith excluded from SDProp (adminCount=0)'
|
if (-not (dsacls.exe $adminSdHolder | Select-String 'svc_backup')) {
|
||||||
} catch {
|
$null = dsacls.exe $adminSdHolder /G '@@NETBIOS@@\svc_backup:GA'
|
||||||
Write-LabLog "dc01: could not clear adminCount ($($_.Exception.Message))"
|
Write-LabLog 'dc01: delegation anchored in AdminSDHolder'
|
||||||
}
|
}
|
||||||
|
|
||||||
# Realistic delegation: the service account manages a plain user who is a
|
# Realistic delegation: the service account manages a plain user who is a
|
||||||
|
|||||||
Reference in New Issue
Block a user