diff options
Diffstat (limited to 'source4/lib/ldb')
-rw-r--r-- | source4/lib/ldb/tools/ldbedit.c | 32 |
1 files changed, 31 insertions, 1 deletions
diff --git a/source4/lib/ldb/tools/ldbedit.c b/source4/lib/ldb/tools/ldbedit.c index 90a6f94750..b97c40ff1a 100644 --- a/source4/lib/ldb/tools/ldbedit.c +++ b/source4/lib/ldb/tools/ldbedit.c @@ -34,6 +34,22 @@ #include "includes.h" +static int verbose; + +/* + debug routine +*/ +static void ldif_write_msg(struct ldb_context *ldb, + FILE *f, + enum ldb_changetype changetype, + struct ldb_message *msg) +{ + struct ldb_ldif ldif; + ldif.changetype = changetype; + ldif.msg = *msg; + ldb_ldif_write_file(ldb, f, &ldif); +} + /* modify a database record so msg1 becomes msg2 returns the number of modified elements @@ -91,6 +107,10 @@ static int modify_record(struct ldb_context *ldb, return -1; } + if (verbose > 0) { + ldif_write_msg(ldb, stdout, LDB_CHANGETYPE_MODIFY, &mod); + } + return count; } @@ -130,6 +150,9 @@ static int merge_edits(struct ldb_context *ldb, msgs2[i]->dn, ldb_errstring(ldb)); return -1; } + if (verbose > 0) { + ldif_write_msg(ldb, stdout, LDB_CHANGETYPE_ADD, msgs2[i]); + } adds++; } else { if (modify_record(ldb, msg, msgs2[i]) > 0) { @@ -147,6 +170,9 @@ static int merge_edits(struct ldb_context *ldb, msgs1[i]->dn, ldb_errstring(ldb)); return -1; } + if (verbose > 0) { + ldif_write_msg(ldb, stdout, LDB_CHANGETYPE_DELETE, msgs1[i]); + } deletes++; } } @@ -295,7 +321,7 @@ static void usage(void) editor = "vi"; } - while ((opt = getopt(argc, argv, "hab:e:H:s:")) != EOF) { + while ((opt = getopt(argc, argv, "hab:e:H:s:v")) != EOF) { switch (opt) { case 'b': basedn = optarg; @@ -323,6 +349,10 @@ static void usage(void) expression = "(|(objectclass=*)(dn=*))"; break; + case 'v': + verbose++; + break; + case 'h': default: usage(); |