summaryrefslogtreecommitdiff
path: root/source3/libads
diff options
context:
space:
mode:
authorGuenther Deschner <gd@samba.org>2019-04-01 17:40:03 +0200
committerAndrew Bartlett <abartlet@samba.org>2019-04-02 01:12:10 +0000
commit2044ca0e20bd3180720a82506b3af041d14b5c68 (patch)
tree03c84c739731cebe03ad4fcbc566b18375395c93 /source3/libads
parentc016afc832543514ebf7ecda1fbe6b272ea533d6 (diff)
downloadsamba-2044ca0e20bd3180720a82506b3af041d14b5c68.tar.gz
s3:ldap: Leave add machine code early for pre-existing accounts
This avoids numerous LDAP constraint violation errors when we try to re-precreate an already existing machine account. BUG: https://bugzilla.samba.org/show_bug.cgi?id=13861 Pair-Programmed-With: Andreas Schneider <asn@samba.org> Signed-off-by: Guenther Deschner <gd@samba.org> Signed-off-by: Andreas Schneider <asn@samba.org> Reviewed-by: Ralph Boehme <slow@samba.org> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Diffstat (limited to 'source3/libads')
-rw-r--r--source3/libads/ldap.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/source3/libads/ldap.c b/source3/libads/ldap.c
index 8fade1027b7..4f3d43b02b1 100644
--- a/source3/libads/ldap.c
+++ b/source3/libads/ldap.c
@@ -2120,6 +2120,15 @@ ADS_STATUS ads_create_machine_acct(ADS_STRUCT *ads,
goto done;
}
+ ret = ads_find_machine_acct(ads, &res, machine_escaped);
+ ads_msgfree(ads, res);
+ if (ADS_ERR_OK(ret)) {
+ DBG_DEBUG("Host account for %s already exists.\n",
+ machine_escaped);
+ ret = ADS_ERROR_LDAP(LDAP_ALREADY_EXISTS);
+ goto done;
+ }
+
new_dn = talloc_asprintf(ctx, "cn=%s,%s", machine_escaped, org_unit);
samAccountName = talloc_asprintf(ctx, "%s$", machine_name);
@@ -2155,7 +2164,6 @@ ADS_STATUS ads_create_machine_acct(ADS_STRUCT *ads,
done:
SAFE_FREE(machine_escaped);
- ads_msgfree(ads, res);
talloc_destroy(ctx);
return ret;