From: Douglas Bagnall Date: Thu, 11 Oct 2018 00:07:30 +0000 (+1300) Subject: python/remove_dc: use a local variable in offline_remove_server X-Git-Tag: tdb-1.3.17~1161 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d6072cbf9808723e1054f3533371aac078a6dd08;p=thirdparty%2Fsamba.git python/remove_dc: use a local variable in offline_remove_server Signed-off-by: Douglas Bagnall Reviewed-by: Noel Power --- diff --git a/python/samba/remove_dc.py b/python/samba/remove_dc.py index a6062703f24..e6b1b7bdc04 100644 --- a/python/samba/remove_dc.py +++ b/python/samba/remove_dc.py @@ -229,15 +229,15 @@ def offline_remove_server(samdb, logger, scope=ldb.SCOPE_BASE, expression="(objectClass=server)") msg = msgs[0] - dc_name = str(msgs[0]["cn"][0]) + dc_name = str(msg["cn"][0]) try: - computer_dn = ldb.Dn(samdb, msgs[0]["serverReference"][0].decode('utf8')) + computer_dn = ldb.Dn(samdb, msg["serverReference"][0].decode('utf8')) except KeyError: computer_dn = None try: - dnsHostName = str(msgs[0]["dnsHostName"][0]) + dnsHostName = str(msg["dnsHostName"][0]) except KeyError: dnsHostName = None @@ -267,8 +267,8 @@ def offline_remove_server(samdb, logger, logger.info("Removing computer account: %s (and any child objects)" % computer_dn) samdb.delete(computer_dn, ["tree_delete:0"]) - if "dnsHostName" in msgs[0]: - dnsHostName = str(msgs[0]["dnsHostName"][0]) + if "dnsHostName" in msg: + dnsHostName = str(msg["dnsHostName"][0]) if remove_dns_account: res = samdb.search(expression="(&(objectclass=user)(cn=dns-%s)(servicePrincipalName=DNS/%s))" %