int main(int argc, const char **argv) { struct ldb_context *ldb; int ret; struct ldb_cmdline *options; const struct ldb_dn *dn1, *dn2; ldb_global_init(); ldb = ldb_init(NULL); options = ldb_cmdline_process(ldb, argc, argv, usage); if (options->argc < 2) { usage(); } dn1 = ldb_dn_explode(ldb, options->argv[0]); dn2 = ldb_dn_explode(ldb, options->argv[1]); ret = ldb_rename(ldb, dn1, dn2); if (ret == 0) { printf("Renamed 1 record\n"); } else { printf("rename of '%s' to '%s' failed - %s\n", options->argv[0], options->argv[1], ldb_errstring(ldb)); } talloc_free(ldb); return ret; }
int main(int argc, const char **argv) { struct ldb_context *ldb; int count=0; int i, ret=LDB_SUCCESS; struct ldb_cmdline *options; ldb = ldb_init(NULL, NULL); options = ldb_cmdline_process(ldb, argc, argv, usage); if (options->argc == 0) { ret = process_file(ldb, stdin, &count); } else { for (i=0;i<options->argc;i++) { const char *fname = options->argv[i]; FILE *f; f = fopen(fname, "r"); if (!f) { perror(fname); exit(1); } ret = process_file(ldb, f, &count); fclose(f); } } talloc_free(ldb); printf("Modified %d records with %d failures\n", count, failures); return ret; }
int main(int argc, const char **argv) { struct ldb_context *ldb; unsigned int i, count = 0; int ret = LDB_SUCCESS; TALLOC_CTX *mem_ctx = talloc_new(NULL); ldb = ldb_init(mem_ctx, NULL); if (ldb == NULL) { return LDB_ERR_OPERATIONS_ERROR; } options = ldb_cmdline_process(ldb, argc, argv, usage); ret = ldb_transaction_start(ldb); if (ret != LDB_SUCCESS) { printf("Failed to start transaction: %s\n", ldb_errstring(ldb)); return ret; } if (options->argc == 0) { ret = process_file(ldb, stdin, &count); } else { for (i=0;i<options->argc;i++) { const char *fname = options->argv[i]; FILE *f; f = fopen(fname, "r"); if (!f) { perror(fname); return LDB_ERR_OPERATIONS_ERROR; } ret = process_file(ldb, f, &count); fclose(f); } } if (count != 0) { ret = ldb_transaction_commit(ldb); if (ret != LDB_SUCCESS) { printf("Failed to commit transaction: %s\n", ldb_errstring(ldb)); return ret; } } else { ldb_transaction_cancel(ldb); } talloc_free(mem_ctx); if (ret) { printf("Add failed after processing %u records\n", count); } else { printf("Added %u records successfully\n", count); } return ret; }
int main(int argc, const char **argv) { struct ldb_context *ldb; int ret = 0, i; struct ldb_cmdline *options; ldb = ldb_init(NULL, NULL); options = ldb_cmdline_process(ldb, argc, argv, usage); if (options->argc < 1) { usage(); exit(1); } for (i=0;i<options->argc;i++) { struct ldb_dn *dn; dn = ldb_dn_new(ldb, ldb, options->argv[i]); if ( ! ldb_dn_validate(dn)) { printf("Invalid DN format\n"); exit(1); } if (options->recursive) { ret = ldb_delete_recursive(ldb, dn); } else { ret = ldb_delete(ldb, dn); if (ret == 0) { printf("Deleted 1 record\n"); } } if (ret != 0) { printf("delete of '%s' failed - %s\n", ldb_dn_get_linearized(dn), ldb_errstring(ldb)); } } talloc_free(ldb); return ret; }
int main(int argc, const char **argv) { struct ldb_context *ldb; int ret; struct ldb_cmdline *options; struct ldb_dn *dn1, *dn2; TALLOC_CTX *mem_ctx = talloc_new(NULL); ldb = ldb_init(mem_ctx, NULL); if (ldb == NULL) { return LDB_ERR_OPERATIONS_ERROR; } options = ldb_cmdline_process(ldb, argc, argv, usage); if (options->argc < 2) { usage(ldb); } dn1 = ldb_dn_new(ldb, ldb, options->argv[0]); dn2 = ldb_dn_new(ldb, ldb, options->argv[1]); if ((dn1 == NULL) || (dn2 == NULL)) { return LDB_ERR_OPERATIONS_ERROR; } ret = ldb_rename(ldb, dn1, dn2); if (ret == LDB_SUCCESS) { printf("Renamed 1 record\n"); } else { printf("rename of '%s' to '%s' failed - %s\n", options->argv[0], options->argv[1], ldb_errstring(ldb)); } talloc_free(mem_ctx); return ret; }