summaryrefslogtreecommitdiff
path: root/source4/lib
diff options
context:
space:
mode:
authorStefan Metzmacher <metze@samba.org>2010-05-21 11:30:20 +0200
committerStefan Metzmacher <metze@samba.org>2010-05-21 13:59:55 +0200
commit5fe476b6821b731db11225043756470c45c7f66c (patch)
treec115f0b5283a6d35f0d0cfe6c796424cbf33b747 /source4/lib
parentab093ffe4637db65afb3779f592f20dd55f4e5f3 (diff)
downloadsamba-5fe476b6821b731db11225043756470c45c7f66c.tar.gz
samba-5fe476b6821b731db11225043756470c45c7f66c.tar.bz2
samba-5fe476b6821b731db11225043756470c45c7f66c.zip
s4:ldb: add --controls support to ldbedit
metze
Diffstat (limited to 'source4/lib')
-rw-r--r--source4/lib/ldb/tools/ldbedit.c17
1 files changed, 12 insertions, 5 deletions
diff --git a/source4/lib/ldb/tools/ldbedit.c b/source4/lib/ldb/tools/ldbedit.c
index 1866cc373e..66354666a6 100644
--- a/source4/lib/ldb/tools/ldbedit.c
+++ b/source4/lib/ldb/tools/ldbedit.c
@@ -33,6 +33,7 @@
#include "ldb_includes.h"
#include "ldb.h"
#include "tools/cmdline.h"
+#include "tools/ldbutil.h"
static struct ldb_cmdline *options;
@@ -56,7 +57,8 @@ static void ldif_write_msg(struct ldb_context *ldb,
*/
static int modify_record(struct ldb_context *ldb,
struct ldb_message *msg1,
- struct ldb_message *msg2)
+ struct ldb_message *msg2,
+ struct ldb_control **req_ctrls)
{
struct ldb_message *mod;
@@ -74,7 +76,7 @@ static int modify_record(struct ldb_context *ldb,
ldif_write_msg(ldb, stdout, LDB_CHANGETYPE_MODIFY, mod);
}
- if (ldb_modify(ldb, mod) != 0) {
+ if (ldb_modify_ctrl(ldb, mod, req_ctrls) != 0) {
fprintf(stderr, "failed to modify %s - %s\n",
ldb_dn_get_linearized(msg1->dn), ldb_errstring(ldb));
return -1;
@@ -111,6 +113,11 @@ static int merge_edits(struct ldb_context *ldb,
struct ldb_message *msg;
int ret = 0;
int adds=0, modifies=0, deletes=0;
+ struct ldb_control **req_ctrls = ldb_parse_control_strings(ldb, ldb, (const char **)options->controls);
+ if (options->controls != NULL && req_ctrls == NULL) {
+ fprintf(stderr, "parsing controls failed: %s\n", ldb_errstring(ldb));
+ return -1;
+ }
if (ldb_transaction_start(ldb) != 0) {
fprintf(stderr, "Failed to start transaction: %s\n", ldb_errstring(ldb));
@@ -124,7 +131,7 @@ static int merge_edits(struct ldb_context *ldb,
if (options->verbose > 0) {
ldif_write_msg(ldb, stdout, LDB_CHANGETYPE_ADD, msgs2[i]);
}
- if (ldb_add(ldb, msgs2[i]) != 0) {
+ if (ldb_add_ctrl(ldb, msgs2[i], req_ctrls) != 0) {
fprintf(stderr, "failed to add %s - %s\n",
ldb_dn_get_linearized(msgs2[i]->dn),
ldb_errstring(ldb));
@@ -133,7 +140,7 @@ static int merge_edits(struct ldb_context *ldb,
}
adds++;
} else {
- if (modify_record(ldb, msg, msgs2[i]) > 0) {
+ if (modify_record(ldb, msg, msgs2[i], req_ctrls) > 0) {
modifies++;
}
}
@@ -146,7 +153,7 @@ static int merge_edits(struct ldb_context *ldb,
if (options->verbose > 0) {
ldif_write_msg(ldb, stdout, LDB_CHANGETYPE_DELETE, msgs1[i]);
}
- if (ldb_delete(ldb, msgs1[i]->dn) != 0) {
+ if (ldb_delete_ctrl(ldb, msgs1[i]->dn, req_ctrls) != 0) {
fprintf(stderr, "failed to delete %s - %s\n",
ldb_dn_get_linearized(msgs1[i]->dn),
ldb_errstring(ldb));