4 Copyright (C) Andrew Tridgell 2004
5 Copyright (C) Stefan Metzmacher 2004
7 ** NOTE! The following LGPL license applies to the ldb
8 ** library. This does NOT imply that all of Samba is released
11 This library is free software; you can redistribute it and/or
12 modify it under the terms of the GNU Lesser General Public
13 License as published by the Free Software Foundation; either
14 version 2 of the License, or (at your option) any later version.
16 This library is distributed in the hope that it will be useful,
17 but WITHOUT ANY WARRANTY; without even the implied warranty of
18 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 Lesser General Public License for more details.
21 You should have received a copy of the GNU Lesser General Public
22 License along with this library; if not, write to the Free Software
23 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
29 * Component: ldbrename
31 * Description: utility to rename records - modelled on ldapmodrdn
33 * Author: Andrew Tridgell
34 * Author: Stefan Metzmacher
39 static void usage(void)
41 printf("Usage: ldbrename [<options>] <olddn> <newdn>\n");
43 printf(" -H ldb_url choose the database (or $LDB_URL)\n");
45 printf("Renames records in a ldb\n\n");
50 int main(int argc, char * const argv[])
52 struct ldb_context *ldb;
56 ldb_url = getenv("LDB_URL");
58 while ((opt = getopt(argc, argv, "hH:")) != EOF) {
72 fprintf(stderr, "You must specify a ldb URL\n\n");
79 ldb = ldb_connect(ldb_url, 0, NULL);
82 perror("ldb_connect");
86 ldb_set_debug_stderr(ldb);
92 ret = ldb_rename(ldb, argv[0], argv[1]);
94 printf("Renamed 1 record\n");
96 printf("rename of '%s' to '%s' failed - %s\n",
97 argv[0], argv[1], ldb_errstring(ldb));