r609: allow ldbedit to take a list of attributes to edit, just like
authorAndrew Tridgell <tridge@samba.org>
Sun, 9 May 2004 12:37:35 +0000 (12:37 +0000)
committerGerald (Jerry) Carter <jerry@samba.org>
Wed, 10 Oct 2007 17:51:51 +0000 (12:51 -0500)
ldbsearch. This allows you to edit the description of all users using
something like:

  ldbedit 'objectclass=user' description

and not get overwhelmed with fields. It also allows you to edit HIDDEN attributes
by specifying them explicitly
(This used to be commit dd83d39de23cdf8c574005829972dae8dc6bee6a)

source4/lib/ldb/tools/ldbedit.c

index debe06c23192aff49c814dc3078be1c548e0b5b3..7e417024222713a02e8fc51f8a2f76297f2a0568 100644 (file)
@@ -260,7 +260,7 @@ static int do_edit(struct ldb_context *ldb, struct ldb_message **msgs1, int coun
 
 static void usage(void)
 {
-       printf("Usage: ldbedit <options> <expression>\n");
+       printf("Usage: ldbedit <options> <expression> <attributes ...>\n");
        printf("Options:\n");
        printf("  -H ldb_url       choose the database (or $LDB_URL)\n");
        printf("  -s base|sub|one  choose search scope\n");
@@ -281,6 +281,7 @@ static void usage(void)
        int opt;
        enum ldb_scope scope = LDB_SCOPE_SUBTREE;
        const char *editor;
+       const char * const * attrs = NULL;
 
        ldb_url = getenv("LDB_URL");
 
@@ -342,6 +343,12 @@ static void usage(void)
                        usage();
                }
                expression = argv[0];
+               argc--;
+               argv++;
+       }
+
+       if (argc > 0) {
+               attrs = (const char * const *)argv;
        }
 
        ldb = ldb_connect(ldb_url, 0, NULL);
@@ -353,7 +360,7 @@ static void usage(void)
 
        ldb_set_debug_stderr(ldb);
 
-       ret = ldb_search(ldb, basedn, scope, expression, NULL, &msgs);
+       ret = ldb_search(ldb, basedn, scope, expression, attrs, &msgs);
 
        if (ret == -1) {
                printf("search failed - %s\n", ldb_errstring(ldb));