mirror of
https://github.com/samba-team/samba.git
synced 2025-07-23 20:59:10 +03:00
samba-tool domain demote: Remove correct DNs and from the correct locations
The previous code missed the CN=DFSR-GlobalSettings children and did not cope with subdomains. The root DN may not be the domain DN if we are a subdomain. Signed-off-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Garming Sam <garming@catalyst.net.nz>
This commit is contained in:
@ -33,12 +33,19 @@ class DemoteException(Exception):
|
||||
|
||||
def remove_sysvol_references(samdb, rdn):
|
||||
realm = samdb.domain_dns_name()
|
||||
for s in ("CN=Enterprise,CN=Microsoft System Volumes,CN=System,CN=Configuration",
|
||||
"CN=%s,CN=Microsoft System Volumes,CN=System,CN=Configuration" % realm,
|
||||
for s in ("CN=Enterprise,CN=Microsoft System Volumes,CN=System",
|
||||
"CN=%s,CN=Microsoft System Volumes,CN=System" % realm):
|
||||
try:
|
||||
samdb.delete(ldb.Dn(samdb,
|
||||
"%s,%s,%s" % (str(rdn), s, str(samdb.get_config_basedn()))))
|
||||
except ldb.LdbError, l:
|
||||
pass
|
||||
|
||||
for s in ("CN=Topology,CN=Domain System Volume,CN=DFSR-GlobalSettings,CN=System",
|
||||
"CN=Domain System Volumes (SYSVOL share),CN=File Replication Service,CN=System"):
|
||||
try:
|
||||
samdb.delete(ldb.Dn(samdb,
|
||||
"%s,%s,%s" % (str(rdn), s, str(samdb.get_root_basedn()))))
|
||||
"%s,%s,%s" % (str(rdn), s, str(samdb.get_default_basedn()))))
|
||||
except ldb.LdbError, l:
|
||||
pass
|
||||
|
||||
|
Reference in New Issue
Block a user