summaryrefslogtreecommitdiff
path: root/python/samba/remove_dc.py
AgeCommit message (Collapse)AuthorFilesLines
2023-08-30python: Fix spellingJoseph Sutton1-3/+3
Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2023-06-23python:samba: Fix code spellingAndreas Schneider1-2/+2
Signed-off-by: Andreas Schneider <asn@samba.org> Reviewed-by: Andrew Bartlett <abartlet@samba.org> Autobuild-User(master): Andreas Schneider <asn@cryptomilk.org> Autobuild-Date(master): Fri Jun 23 14:51:14 UTC 2023 on atb-devel-224
2022-10-05python: Handle LdbError thrown from functions operating on DNsJoseph Sutton1-4/+12
None of these functions can return False now. Instead we must catch the LdbError if we want to perform further error handling. Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2022-05-10python: Remove unnecessary 'pass' statementsJoseph Sutton1-2/+0
Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz> Reviewed-by: Andreas Schneider <asn@samba.org>
2018-11-01python/remove_dc: fix Exception constructionDouglas Bagnall1-4/+5
Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Noel Power <noel.power@suse.com>
2018-11-01python/remove_dc: fix formating syntax (missing %s)Douglas Bagnall1-2/+2
Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Noel Power <noel.power@suse.com>
2018-10-25python/remove_dc: use a local variable in offline_remove_serverDouglas Bagnall1-5/+5
Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Noel Power <npower@samba.org>
2018-09-15python/samba: PY3 port for ridalloc_exop test to workNoel Power1-2/+2
Signed-off-by: Noel Power <noel.power@suse.com> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2018-09-06PEP8: fix E127: continuation line over-indented for visual indentJoe Guo1-1/+1
Signed-off-by: Joe Guo <joeg@catalyst.net.nz> Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2018-09-03python/samba/netcmd: changes for samab.tests.samba_tool.computerNoel Power1-1/+1
Signed-off-by: Noel Power <noel.power@suse.com> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2018-08-24PEP8: fix E502: the backslash is redundant between bracketsJoe Guo1-5/+5
Signed-off-by: Joe Guo <joeg@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
2018-08-24PEP8: fix E303: too many blank lines (2)Joe Guo1-1/+0
Signed-off-by: Joe Guo <joeg@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
2018-08-24PEP8: fix E302: expected 2 blank lines, found 1Joe Guo1-0/+2
Signed-off-by: Joe Guo <joeg@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
2018-08-24PEP8: fix E202: whitespace before ')'Joe Guo1-2/+2
Signed-off-by: Joe Guo <joeg@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
2018-08-24PEP8: fix E201: whitespace after '('Joe Guo1-2/+2
Signed-off-by: Joe Guo <joeg@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
2018-08-24PEP8: fix E128: continuation line under-indented for visual indentJoe Guo1-3/+3
Signed-off-by: Joe Guo <joeg@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
2018-08-24PEP8: fix E127: continuation line over-indented for visual indentJoe Guo1-1/+1
Signed-off-by: Joe Guo <joeg@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
2018-08-24PEP8: fix E111: indentation is not a multiple of fourJoe Guo1-1/+1
Signed-off-by: Joe Guo <joeg@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
2018-07-05netcmd: Extend 'backup restore' command to handle renamed domainsTim Beale1-1/+2
When restoring a renamed domain backup, we need to register the new realm's DNS zone. We do this in the restore step because we don't know the new server's IP/hostname in the backup step. Because we may have removed the old realm's DNS entries in the rename step, the remove_dc() code may fail to find the expected DNS entries for the DC's domain (the DCs' dnsHostname still maps to the old DNS realm). We just needed to adjust remove_dns_references() as it was getting a slightly different error code. Signed-off-by: Tim Beale <timbeale@catalyst.net.nz> Reviewed-by: Gary Lockyer <gary@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2018-06-26remove_dc: Fix removal of an old Windows DCTim Beale1-2/+3
Windows has 'CN=DNS Settings' child object underneath the Server object. This was causing the removal of the server object in remove_dc() to fail. Noticed this problem while testing the backup/restore tool manually against a Windows VM. BUG: https://bugzilla.samba.org/show_bug.cgi?id=13484 Signed-off-by: Tim Beale <timbeale@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Gary Lockyer <gary@catalyst.net.nz> Autobuild-User(master): Gary Lockyer <gary@samba.org> Autobuild-Date(master): Tue Jun 26 23:32:51 CEST 2018 on sn-devel-144
2018-04-30python: Bulk conversion callers of ldb.Dn second paramNoel Power1-2/+2
Convert second param passed to ldb.Dn to be unicode so py2 & py3 code will work Signed-off-by: Noel Power <noel.power@suse.com> Reviewed-by: Alexander Bokovoy <ab@samba.org>
2018-03-05remove_dc.py: Abort transaction before throwing an exceptionGary Lockyer1-0/+3
Signed-off-by: Gary Lockyer <gary@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2018-02-28samba python libs: convert 'except X, (tuple)' to 'except X as e'Noel Power1-8/+16
In addition to converting the except line another line is also added for each except to extract the tuple contents. Signed-off-by: Noel Power <noel.power@suse.com> Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2018-02-08remove_dc: Allow remove_dns_references to ignore missing server namesGarming Sam1-2/+12
Signed-off-by: Garming Sam <garming@catalyst.net.nz> Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
2017-06-10pydns: Also return the DN of the LDB object when finding a DNS recordAndrew Bartlett1-2/+2
Signed-off-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Garming Sam <garming@catalyst.net.nz>
2017-03-10python/remove_dc: avoid using non-existent variableDouglas Bagnall1-2/+2
Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Signed-off-by: Andrew Bartlett <abartlet@samba.org>
2017-02-14python: Use generated WERROR definitionsBob Campbell1-2/+3
Previously we either defined WERRORs locally or compared them against strings where we needed to use them. Signed-off-by: Bob Campbell <bobcampbell@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Garming Sam <garming@catalyst.net.nz>
2016-07-13python/remove_dc: handle dnsNode objects without dnsRecord attributeStefan Metzmacher1-6/+5
If we have dnsNode objects without dnsRecord attribute values we trigger the following error triggered by 'samba-tool domain demote --remove-other-dead-server=server2' ERROR(<type 'exceptions.TypeError'>): uncaught exception - __ndr_unpack__() argument 1 must be string or read-only buffer, not dnsp.DnssrvRpcRecord File "/usr/lib64/python2.6/site-packages/samba/netcmd/__init__.py", line 175, in _run return self.run(*args, **kwargs) File "/usr/lib64/python2.6/site-packages/samba/netcmd/domain.py", line 720, in run remove_dc.remove_dc(samdb, logger, remove_other_dead_server) File "/usr/lib64/python2.6/site-packages/samba/remove_dc.py", line 423, in remove_dc remove_dns_account=True) File "/usr/lib64/python2.6/site-packages/samba/remove_dc.py", line 351, in offline_remove_ntds_dc remove_dns_account=remove_dns_account) File "/usr/lib64/python2.6/site-packages/samba/remove_dc.py", line 266, in offline_remove_server remove_dns_references(samdb, logger, dnsHostName) File "/usr/lib64/python2.6/site-packages/samba/remove_dc.py", line 186, in remove_dns_references for v in values if not to_remove(v) ] File "/usr/lib64/python2.6/site-packages/samba/remove_dc.py", line 160, in to_remove dnsRecord = ndr_unpack(dnsp.DnssrvRpcRecord, value) File "/usr/lib64/python2.6/site-packages/samba/ndr.py", line 45, in ndr_unpack object.__ndr_unpack__(data, allow_remaining=allow_remaining) A transaction is still active in ldb context [0xe1f320] on tdb:///var/lib/samba/private/sam.ldb "next" is used in perl not in python! BUG: https://bugzilla.samba.org/show_bug.cgi?id=12018 Signed-off-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Andrew Bartlett <abartlet@samba.org> Autobuild-User(master): Andrew Bartlett <abartlet@samba.org> Autobuild-Date(master): Wed Jul 13 10:10:30 CEST 2016 on sn-devel-144
2015-10-26samba-tool domain demote: Add support for removing by NTDS GUIDAndrew Bartlett1-33/+57
This would help remove a DC that is a conflict record, for example Signed-off-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Garming Sam <garming@catalyst.net.nz>
2015-10-26samba-tool domain demote: Add --verbose and --quiet optionsAndrew Bartlett1-18/+37
Signed-off-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Garming Sam <garming@catalyst.net.nz>
2015-10-26samba-tool domain demote: Remove dns-SERVER object as wellAndrew Bartlett1-6/+20
This object is not in standard AD, but Marc Muehlfeld correctly notes that Samba creates it for BIND9_DLZ Signed-off-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Garming Sam <garming@catalyst.net.nz>
2015-10-26samba-tool domain demote: Remove all references to the demoted host, even in DNSAndrew Bartlett1-2/+96
We search the in-directory DNS records for entries that point to the name or IP that the dead DC was using, and remove them Signed-off-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Garming Sam <garming@catalyst.net.nz>
2015-10-26samba-tool domain demote: Use dn.add_base/dn.add_childAndrew Bartlett1-14/+42
This is done primarilly to set the pattern that we should manipulate ldb.Dn values with the helper routines, not just by concatonation via format strings. We also restrict our exception hadling to only the expected errors, not all errors. Andrew Bartlett Signed-off-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Garming Sam <garming@catalyst.net.nz>
2015-10-26samba-tool domain demote: Remove correct DNs and from the correct locationsAndrew Bartlett1-3/+10
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>
2015-10-26samba-tool domain demote: Refuse to remove ourselfAndrew Bartlett1-2/+6
This ensures that a different server is the one being demoted from the local database Signed-off-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Garming Sam <garming@catalyst.net.nz>
2015-10-26samba-tool domain demote: Rework to allow cleanup of partial demotion, catch ↵Andrew Bartlett1-52/+114
more errors Signed-off-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Garming Sam <garming@catalyst.net.nz>
2015-10-26samba-tool domain demote: Add --remove-other-dead-serverAndrew Bartlett1-0/+183
The new version of this tool now can remove another DC that is itself offline. The --remove-other-dead-server removes as many references to the DC as possible. Signed-off-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Garming Sam <garming@catalyst.net.nz>