4bc27b
From ad4ef1657e9b2a088a3bfadcce196cfcceead1dc Mon Sep 17 00:00:00 2001
4bc27b
From: Evgeny Sinelnikov <sin@altlinux.org>
4bc27b
Date: Wed, 31 Jul 2019 23:17:20 +0400
4bc27b
Subject: [PATCH] s3:ldap: Fix join with don't exists machine account
4bc27b
MIME-Version: 1.0
4bc27b
Content-Type: text/plain; charset=UTF-8
4bc27b
Content-Transfer-Encoding: 8bit
4bc27b
4bc27b
Add check for requested replies of existing machine object during join
4bc27b
machine to domain. This solves regression fail during join with error:
4bc27b
"None of the information to be translated has been translated."
4bc27b
4bc27b
https://bugzilla.samba.org/show_bug.cgi?id=14007
4bc27b
4bc27b
Reviewed-by: Guenther Deschner <gd@samba.org>
4bc27b
Reviewed-by: Alexander Bokovoy <ab@samba.org>
4bc27b
Reviewed-by: Stefan Metzmacher <metze@samba.org>
4bc27b
4bc27b
Autobuild-User(master): Günther Deschner <gd@samba.org>
4bc27b
Autobuild-Date(master): Wed Sep  4 17:02:37 UTC 2019 on sn-devel-184
4bc27b
---
4bc27b
 source3/libads/ldap.c | 5 +++--
4bc27b
 1 file changed, 3 insertions(+), 2 deletions(-)
4bc27b
4bc27b
diff --git a/source3/libads/ldap.c b/source3/libads/ldap.c
4bc27b
index 4f3d43b02b1..2110390b65f 100644
4bc27b
--- a/source3/libads/ldap.c
4bc27b
+++ b/source3/libads/ldap.c
4bc27b
@@ -2121,13 +2121,14 @@ ADS_STATUS ads_create_machine_acct(ADS_STRUCT *ads,
4bc27b
 	}
4bc27b
 
4bc27b
 	ret = ads_find_machine_acct(ads, &res, machine_escaped);
4bc27b
-	ads_msgfree(ads, res);
4bc27b
-	if (ADS_ERR_OK(ret)) {
4bc27b
+	if (ADS_ERR_OK(ret) && ads_count_replies(ads, res) == 1) {
4bc27b
 		DBG_DEBUG("Host account for %s already exists.\n",
4bc27b
 				machine_escaped);
4bc27b
 		ret = ADS_ERROR_LDAP(LDAP_ALREADY_EXISTS);
4bc27b
+		ads_msgfree(ads, res);
4bc27b
 		goto done;
4bc27b
 	}
4bc27b
+	ads_msgfree(ads, res);
4bc27b
 
4bc27b
 	new_dn = talloc_asprintf(ctx, "cn=%s,%s", machine_escaped, org_unit);
4bc27b
 	samAccountName = talloc_asprintf(ctx, "%s$", machine_name);
4bc27b
-- 
4bc27b
2.21.0
4bc27b