mirror of
https://github.com/samba-team/samba.git
synced 2025-08-04 08:22:08 +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):
|
def remove_sysvol_references(samdb, rdn):
|
||||||
realm = samdb.domain_dns_name()
|
realm = samdb.domain_dns_name()
|
||||||
for s in ("CN=Enterprise,CN=Microsoft System Volumes,CN=System,CN=Configuration",
|
for s in ("CN=Enterprise,CN=Microsoft System Volumes,CN=System",
|
||||||
"CN=%s,CN=Microsoft System Volumes,CN=System,CN=Configuration" % realm,
|
"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"):
|
"CN=Domain System Volumes (SYSVOL share),CN=File Replication Service,CN=System"):
|
||||||
try:
|
try:
|
||||||
samdb.delete(ldb.Dn(samdb,
|
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:
|
except ldb.LdbError, l:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user