net: add "net idmap get config" to read the autorid config from the database
authorAtul Kulkarni <atul.kulkarni@in.ibm.com>
Mon, 12 Aug 2013 07:39:31 +0000 (13:09 +0530)
committerMichael Adam <obnox@samba.org>
Tue, 1 Oct 2013 08:49:23 +0000 (10:49 +0200)
Pair-Programmed-With: Michael Adam <obnox@samba.org>

Signed-off-by: Atul Kulkarni <atul.kulkarni@in.ibm.com>
Signed-off-by: Michael Adam <obnox@samba.org>
source3/utils/net_idmap.c

index e29792502aee2db6ddcadd03f934dc029d6e8388..016ce85dd4896d7fb4625b85fc695fa93124c80b 100644 (file)
@@ -807,9 +807,59 @@ static int net_idmap_set(struct net_context *c, int argc, const char **argv)
        return net_run_function(c, argc, argv, "net idmap set", func);
 }
 
+static int net_idmap_autorid_get_config(struct net_context *c, int argc,
+                                       const char **argv)
+{
+       int ret = -1;
+       char *config;
+       TALLOC_CTX *mem_ctx;
+       NTSTATUS status;
+       struct db_context *db = NULL;
+
+       if (argc > 0 || c->display_usage) {
+               d_printf("%s\n%s",
+                        _("Usage:"),
+                        _("net idmap get config"
+                          " [--db=<inputfile>]\n"
+                          " Get CONFIG entry from autorid database\n"
+                          "    inputfile\tTDB file to read config from.\n"));
+               return c->display_usage ? 0 : -1;
+       }
+
+       mem_ctx = talloc_stackframe();
+
+       if (!net_idmap_opendb_autorid(mem_ctx, c, true, &db)) {
+               goto done;
+       }
+
+       status = idmap_autorid_getconfigstr(db, mem_ctx, &config);
+       if (!NT_STATUS_IS_OK(status)) {
+               d_fprintf(stderr, "%s: %s\n",
+                         _("Error: unable to read config entry"),
+                         nt_errstr(status));
+               goto done;
+       }
+
+       printf("CONFIG: %s\n", config);
+       ret = 0;
+
+done:
+       talloc_free(mem_ctx);
+       return ret;
+}
+
+
 static int net_idmap_get(struct net_context *c, int argc, const char **argv)
 {
        struct functable func[] = {
+               {
+                       "config",
+                       net_idmap_autorid_get_config,
+                       NET_TRANSPORT_LOCAL,
+                       N_("Get the global configuration from the autorid database"),
+                       N_("net idmap get config \n"
+                          "  Get the global configuration from the autorid database ")
+               },
                {NULL, NULL, 0, NULL, NULL}
        };