idmap_autorid: add idmap_autorid_saveconfigstr()
authorMichael Adam <obnox@samba.org>
Mon, 9 Sep 2013 23:45:52 +0000 (01:45 +0200)
committerMichael Adam <obnox@samba.org>
Tue, 1 Oct 2013 08:49:22 +0000 (10:49 +0200)
Store a configuration as provided by a config string
after parsing and validating the string.

Based on similar patch by Atul Kulkarni <atul.kulkarni@in.ibm.com>.

Signed-off-by: Michael Adam <obnox@samba.org>
source3/include/idmap_autorid.h
source3/winbindd/idmap_autorid_tdb.c

index d0e1cef4a51d994d6558b30842d522f1263ea068..b629f0f7ee1b8aebc70870c6d680cf48b5d138fc 100644 (file)
@@ -127,4 +127,13 @@ NTSTATUS idmap_autorid_getconfigstr(struct db_context *db, TALLOC_CTX *mem_ctx,
 bool idmap_autorid_parse_configstr(const char *configstr,
                                   struct autorid_global_config *cfg);
 
+
+/**
+ * Save the global autorid configuration into the autorid database
+ * as provided in the config string.
+ * First parse the configstr and validate it.
+ */
+NTSTATUS idmap_autorid_saveconfigstr(struct db_context *db,
+                                    const char *configstr);
+
 #endif /* _IDMAP_AUTORID_H_ */
index ca84b2b3c363be96149cdefd65732e061cfdcff0..2877f42bc365530f55904f8c00ead1dff95fe888 100644 (file)
@@ -695,3 +695,19 @@ done:
        talloc_free(frame);
        return status;
 }
+
+NTSTATUS idmap_autorid_saveconfigstr(struct db_context *db,
+                                    const char *configstr)
+{
+       bool ok;
+       NTSTATUS status;
+       struct autorid_global_config cfg;
+
+       ok = idmap_autorid_parse_configstr(configstr, &cfg);
+       if (!ok) {
+               return NT_STATUS_INVALID_PARAMETER;
+       }
+
+       status = idmap_autorid_saveconfig(db, &cfg);
+       return status;
+}