From 37de963f67a1331b6402f901d2bda79b7119a155 Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Mon, 10 Sep 2007 01:39:20 +0000 Subject: r25048: From the archives (patch found in one of my old working trees): Try two different DNs, when performing a samsync from an AD server. Andrew Bartlett (This used to be commit 8204e261b5c554866a8433362477b532d1123e5d) --- source4/libnet/libnet_samsync_ldb.c | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/source4/libnet/libnet_samsync_ldb.c b/source4/libnet/libnet_samsync_ldb.c index 2c30128b16..1fa4aece19 100644 --- a/source4/libnet/libnet_samsync_ldb.c +++ b/source4/libnet/libnet_samsync_ldb.c @@ -432,14 +432,21 @@ static NTSTATUS samsync_ldb_handle_user(TALLOC_CTX *mem_ctx, if (ret != 0) { struct ldb_dn *first_try_dn = msg->dn; /* Try again with the default DN */ - msg->dn = talloc_steal(msg, msgs[0]->dn); - ret = samdb_add(state->sam_ldb, mem_ctx, msg); - if (ret != 0) { - *error_string = talloc_asprintf(mem_ctx, "Failed to create user record. Tried both %s and %s: %s", + if (!remote_msgs) { + *error_string = talloc_asprintf(mem_ctx, "Failed to create user record. Tried %s: %s", ldb_dn_get_linearized(first_try_dn), - ldb_dn_get_linearized(msg->dn), ldb_errstring(state->sam_ldb)); return NT_STATUS_INTERNAL_DB_CORRUPTION; + } else { + msg->dn = talloc_steal(msg, remote_msgs[0]->dn); + ret = samdb_add(state->sam_ldb, mem_ctx, msg); + if (ret != 0) { + *error_string = talloc_asprintf(mem_ctx, "Failed to create user record. Tried both %s and %s: %s", + ldb_dn_get_linearized(first_try_dn), + ldb_dn_get_linearized(msg->dn), + ldb_errstring(state->sam_ldb)); + return NT_STATUS_INTERNAL_DB_CORRUPTION; + } } } } else { -- cgit