Replace the unrealistic ACL target with a realistic delegation
GenericAll over a Domain Admin cannot survive in a real domain: SDProp rewrites protected objects from AdminSDHolder every hour. The previous design only worked thanks to adminCount=0, which no IT team would ever set. New design, matching what broad delegation actually looks like: svc_backup --GenericAll--> m.legault (plain user, ACE stable) m.legault in Serveurs-Admins, which is in BUILTIN\Administrators on DC01 t.smith stays as a decoy: the same edge exists but is reverted by SDProp, which is itself a lesson. Also repairs accounts that an interrupted first run left disabled (m.legault was one), and doctor now checks the stable path, the account state and the DC admin membership.
This commit is contained in:
@@ -39,7 +39,11 @@ try {
|
||||
|
||||
foreach ($u in $users) {
|
||||
if (Get-ADUser -Filter "SamAccountName -eq '$($u.Sam)'" -ErrorAction SilentlyContinue) {
|
||||
Write-LabLog "dc01: user $($u.Sam) exists"
|
||||
# An interrupted first run can leave an account disabled: repair it.
|
||||
Enable-ADAccount -Identity $u.Sam -ErrorAction SilentlyContinue
|
||||
Set-ADAccountPassword -Identity $u.Sam -Reset `
|
||||
-NewPassword (ConvertTo-SecureString $u.Pwd -AsPlainText -Force)
|
||||
Write-LabLog "dc01: user $($u.Sam) exists (repaired)"
|
||||
continue
|
||||
}
|
||||
$ou = if ($u.OU -eq 'TI') { "OU=TI,OU=Norbourg,$base" } else { "OU=Utilisateurs,OU=Norbourg,$base" }
|
||||
@@ -106,6 +110,23 @@ try {
|
||||
Write-LabLog "dc01: could not clear adminCount ($($_.Exception.Message))"
|
||||
}
|
||||
|
||||
# Realistic delegation: the service account manages a plain user who is a
|
||||
# member of the server-admin group. m.legault is NOT in a protected group,
|
||||
# so SDProp leaves this ACE alone — unlike the Domain Admin target above.
|
||||
$plainDn = (Get-ADUser 'm.legault').DistinguishedName
|
||||
if (-not (dsacls.exe $plainDn | Select-String 'svc_backup')) {
|
||||
$null = dsacls.exe $plainDn /G '@@NETBIOS@@\svc_backup:GA'
|
||||
Write-LabLog 'dc01: GenericAll granted to svc_backup over m.legault'
|
||||
}
|
||||
|
||||
# m.legault reaches DC admin through the server group.
|
||||
try {
|
||||
Add-ADGroupMember -Identity 'S-1-5-32-544' -Members 'Serveurs-Admins' -ErrorAction Stop
|
||||
Write-LabLog 'dc01: Serveurs-Admins added to BUILTIN\Administrators'
|
||||
} catch {
|
||||
Write-LabLog 'dc01: Serveurs-Admins already in BUILTIN\Administrators'
|
||||
}
|
||||
|
||||
# ------------------------------------------------------------ dns
|
||||
try {
|
||||
Add-DnsServerResourceRecordA -Name 'www' -ZoneName '@@DOMAIN@@' -IPv4Address '10.10.10.20' -ErrorAction Stop
|
||||
|
||||
Reference in New Issue
Block a user