diff options
author | Andrew Bartlett <abartlet@samba.org> | 2015-11-26 13:50:21 +1300 |
---|---|---|
committer | Andrew Bartlett <abartlet@samba.org> | 2015-12-15 08:42:20 +0100 |
commit | 308d645f3428660b0466dbe273b995a887af68da (patch) | |
tree | 49d41bf192dfe2e7b6d03bfba51e3fd8cae8e144 | |
parent | d38e22184ea036dfcbe851352729c469a494cb29 (diff) | |
download | samba-308d645f3428660b0466dbe273b995a887af68da.tar.gz |
samba_upgradedns: Improve search for existing accounts in secrets.ldb
We should actually check for the combination of both an account in secrets.ldb
and sam.ldb, but this is at least an improvement.
Signed-off-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Garming Sam <garming@catalyst.net.nz>
-rwxr-xr-x | source4/scripting/bin/samba_upgradedns | 16 |
1 files changed, 6 insertions, 10 deletions
diff --git a/source4/scripting/bin/samba_upgradedns b/source4/scripting/bin/samba_upgradedns index 53e05a6b6df..f57ff729630 100755 --- a/source4/scripting/bin/samba_upgradedns +++ b/source4/scripting/bin/samba_upgradedns @@ -412,21 +412,17 @@ if __name__ == '__main__': # Special stuff for DLZ backend if opts.dns_backend == "BIND9_DLZ": # Check if dns-HOSTNAME account exists and create it if required - try: - dn = 'samAccountName=dns-%s,CN=Principals' % hostname - msg = ldbs.secrets.search(expression='(dn=%s)' % dn, attrs=['secret']) - except IndexError: + secrets_msgs = ldbs.secrets.search(expression='(samAccountName=dns-%s)' % hostname, attrs=['secret']) + if len(secrets_msgs) == 0: logger.info("Adding dns-%s account" % hostname) - try: - msg = ldbs.sam.search(base=domaindn, scope=ldb.SCOPE_DEFAULT, - expression='(sAMAccountName=dns-%s)' % (hostname), - attrs=[]) + msg = ldbs.sam.search(base=domaindn, scope=ldb.SCOPE_DEFAULT, + expression='(sAMAccountName=dns-%s)' % (hostname), + attrs=[]) + if len(msg) == 1: dn = msg[0].dn ldbs.sam.delete(dn) - except IndexError: - pass dnspass = samba.generate_random_password(128, 255) setup_add_ldif(ldbs.sam, setup_path("provision_dns_add_samba.ldif"), { |