r25048: From the archives (patch found in one of my old working trees):
authorAndrew Bartlett <abartlet@samba.org>
Mon, 10 Sep 2007 01:39:20 +0000 (01:39 +0000)
committerGerald (Jerry) Carter <jerry@samba.org>
Wed, 10 Oct 2007 20:05:49 +0000 (15:05 -0500)
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

index 2c30128b16bc11ab356b4f1e6a3e75f2be7f0baf..1fa4aece19c76d3b0d3d9d581b5225b2900c4e2b 100644 (file)
@@ -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 {