summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Bartlett <abartlet@samba.org>2005-10-31 03:44:29 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 13:45:33 -0500
commit56d3064db62c4534f49477a186b746c6c501e3a0 (patch)
tree8544020ab7d53097ef0ab861ba10f05f27764ded
parent4e65f39ca95ee63cd07801578c49af9cb813e316 (diff)
downloadsamba-56d3064db62c4534f49477a186b746c6c501e3a0.tar.gz
samba-56d3064db62c4534f49477a186b746c6c501e3a0.tar.bz2
samba-56d3064db62c4534f49477a186b746c6c501e3a0.zip
r11410: Fix rejoin as a BDC by modifying, rather than trying to recreate, the
server reference. Andrew Bartlett (This used to be commit 302219928f47cdc3822c3a7d9444339092d9d33c)
-rw-r--r--source4/libnet/libnet_join.c39
1 files changed, 37 insertions, 2 deletions
diff --git a/source4/libnet/libnet_join.c b/source4/libnet/libnet_join.c
index a438c5962d..b487056494 100644
--- a/source4/libnet/libnet_join.c
+++ b/source4/libnet/libnet_join.c
@@ -26,6 +26,7 @@
#include "librpc/gen_ndr/ndr_lsa.h"
#include "librpc/gen_ndr/ndr_drsuapi.h"
#include "lib/ldb/include/ldb.h"
+#include "lib/ldb/include/ldb_errors.h"
#include "libcli/cldap/cldap.h"
#include "include/secrets.h"
#include "librpc/gen_ndr/drsuapi.h"
@@ -138,10 +139,44 @@ static NTSTATUS libnet_JoinSite(struct libnet_context *ctx,
}
msg->dn = server_dn;
- msg->elements->flags = LDB_FLAG_MOD_ADD;
rtn = ldb_add(remote_ldb, msg);
- if (rtn != 0) {
+ if (rtn == LDB_ERR_ENTRY_ALREADY_EXISTS) {
+ int i;
+
+ /* make a 'modify' msg, and only for serverReference */
+ msg = ldb_msg_new(tmp_ctx);
+ if (!msg) {
+ libnet_r->out.error_string = NULL;
+ talloc_free(tmp_ctx);
+ return NT_STATUS_NO_MEMORY;
+ }
+ msg->dn = server_dn;
+
+ rtn = ldb_msg_add_string(msg, "serverReference",libnet_r->out.account_dn_str);
+ if (rtn != 0) {
+ libnet_r->out.error_string = NULL;
+ talloc_free(tmp_ctx);
+ return NT_STATUS_NO_MEMORY;
+ }
+
+ /* mark all the message elements (should be just one)
+ as LDB_FLAG_MOD_REPLACE */
+ for (i=0;i<msg->num_elements;i++) {
+ msg->elements[i].flags = LDB_FLAG_MOD_REPLACE;
+ }
+
+ rtn = ldb_modify(remote_ldb, msg);
+ if (rtn != 0) {
+ libnet_r->out.error_string
+ = talloc_asprintf(libnet_r,
+ "Failed to modify server entry %s: %s: %d",
+ server_dn_str,
+ ldb_errstring(remote_ldb), rtn);
+ talloc_free(tmp_ctx);
+ return NT_STATUS_INTERNAL_DB_CORRUPTION;
+ }
+ } else if (rtn != 0) {
libnet_r->out.error_string
= talloc_asprintf(libnet_r,
"Failed to add server entry %s: %s: %d",