diff options
author | Stefan Metzmacher <metze@samba.org> | 2011-04-05 14:42:06 +0200 |
---|---|---|
committer | Stefan Metzmacher <metze@samba.org> | 2011-04-21 14:41:36 +0200 |
commit | e57a23d23f8af229168935681bf3394108df29cd (patch) | |
tree | 574fe6584e04a9cf2aa811874014dc2e6edb808e /source4 | |
parent | a3b952288987e2b62693bdece8c6bd0246f57262 (diff) | |
download | samba-e57a23d23f8af229168935681bf3394108df29cd.tar.gz samba-e57a23d23f8af229168935681bf3394108df29cd.tar.bz2 samba-e57a23d23f8af229168935681bf3394108df29cd.zip |
s4:ldb/tools: add support for "modrdn" to ldbmodify
Signed-off-by: Simo Sorce <idra@samba.org>
metze
Diffstat (limited to 'source4')
-rw-r--r-- | source4/lib/ldb/tools/ldbmodify.c | 24 |
1 files changed, 23 insertions, 1 deletions
diff --git a/source4/lib/ldb/tools/ldbmodify.c b/source4/lib/ldb/tools/ldbmodify.c index 1e7aa80d83..2ca7b62b2c 100644 --- a/source4/lib/ldb/tools/ldbmodify.c +++ b/source4/lib/ldb/tools/ldbmodify.c @@ -61,6 +61,11 @@ static int process_file(struct ldb_context *ldb, FILE *f, unsigned int *count) } while ((ldif = ldb_ldif_read_file(ldb, f))) { + struct ldb_dn *olddn; + bool deleteoldrdn = false; + struct ldb_dn *newdn; + const char *errstr = NULL; + switch (ldif->changetype) { case LDB_CHANGETYPE_NONE: case LDB_CHANGETYPE_ADD: @@ -72,11 +77,28 @@ static int process_file(struct ldb_context *ldb, FILE *f, unsigned int *count) case LDB_CHANGETYPE_MODIFY: ret = ldb_modify_ctrl(ldb, ldif->msg,req_ctrls); break; + case LDB_CHANGETYPE_MODRDN: + ret = ldb_ldif_parse_modrdn(ldb, ldif, ldif, &olddn, + NULL, &deleteoldrdn, + NULL, &newdn); + if (ret == LDB_SUCCESS) { + if (deleteoldrdn) { + ret = ldb_rename(ldb, olddn, newdn); + } else { + errstr = "modrdn: deleteoldrdn=0 " + "not supported."; + ret = LDB_ERR_CONSTRAINT_VIOLATION; + } + } + break; } if (ret != LDB_SUCCESS) { + if (errstr == NULL) { + errstr = ldb_errstring(ldb); + } fprintf(stderr, "ERR: (%s) \"%s\" on DN %s\n", ldb_strerror(ret), - ldb_errstring(ldb), ldb_dn_get_linearized(ldif->msg->dn)); + errstr, ldb_dn_get_linearized(ldif->msg->dn)); failures++; fun_ret = ret; } else { |