diff options
author | Michael Adam <obnox@samba.org> | 2013-09-18 03:19:58 +0200 |
---|---|---|
committer | Michael Adam <obnox@samba.org> | 2013-10-02 00:50:14 +0200 |
commit | 7c2b83d15eb5e64a4ad7b8dcd1bbd73bfe78de24 (patch) | |
tree | cd9cdc5b71241960421103e0913e55c07acd2c7c /source3 | |
parent | a6f6ad8d22e1e1030681e98c10fdd08b8f319d98 (diff) | |
download | samba-7c2b83d15eb5e64a4ad7b8dcd1bbd73bfe78de24.tar.gz samba-7c2b83d15eb5e64a4ad7b8dcd1bbd73bfe78de24.tar.bz2 samba-7c2b83d15eb5e64a4ad7b8dcd1bbd73bfe78de24.zip |
net: implement "net idmap delete ranges"
Inspired by a patch by Atul Kulkarni <atul.kulkarni@in.ibm.com>.
Signed-off-by: Michael Adam <obnox@samba.org>
Reviewed-by: Volker Lendecke <vl@samba.org>
Diffstat (limited to 'source3')
-rw-r--r-- | source3/utils/net_idmap.c | 67 |
1 files changed, 67 insertions, 0 deletions
diff --git a/source3/utils/net_idmap.c b/source3/utils/net_idmap.c index 0a583111f5..6638312277 100644 --- a/source3/utils/net_idmap.c +++ b/source3/utils/net_idmap.c @@ -733,6 +733,64 @@ done: return ret; } +static void net_idmap_autorid_delete_ranges_usage(void) +{ + d_printf("%s\n%s", + _("Usage:"), + _("net idmap delete ranges [-f] [--db=<TDB>] <SID>)\n" + " Delete all domain range mappings for a given domain.\n" + " -f\tforce\n" + " TDB\tidmap database\n" + " SID\t\tSID of the domain\n")); +} + +static int net_idmap_autorid_delete_ranges(struct net_context *c, int argc, + const char **argv) +{ + int ret = -1; + struct db_context *db = NULL; + NTSTATUS status; + const char *domsid; + TALLOC_CTX *mem_ctx = NULL; + bool force = (c->opt_force != 0); + int count = 0; + + if (c->display_usage) { + net_idmap_autorid_delete_ranges_usage(); + return 0; + } + + if (argc != 1) { + net_idmap_autorid_delete_ranges_usage(); + return -1; + } + + domsid = argv[0]; + + mem_ctx = talloc_stackframe(); + if (!net_idmap_opendb_autorid(mem_ctx, c, false, &db)) { + goto done; + } + + status = idmap_autorid_delete_domain_ranges(db, domsid, force, &count); + if (!NT_STATUS_IS_OK(status)) { + d_fprintf(stderr, "%s %s: %s\n", + _("Failed to delete domain range mappings for " + "domain"), + domsid, + nt_errstr(status)); + goto done; + } + + d_printf(_("deleted %d domain mappings\n"), count); + + ret = 0; + +done: + talloc_free(mem_ctx); + return ret; +} + static int net_idmap_delete(struct net_context *c, int argc, const char **argv) { struct functable func[] = { @@ -752,6 +810,15 @@ static int net_idmap_delete(struct net_context *c, int argc, const char **argv) N_("net idmap delete range <RANGE>|(<SID>[ <INDEX>])\n" " Delete a domain range mapping") }, + { + "ranges", + net_idmap_autorid_delete_ranges, + NET_TRANSPORT_LOCAL, + N_("Delete all domain range mapping for a given " + "domain"), + N_("net idmap delete ranges <SID>\n" + " Delete a domain range mapping") + }, {NULL, NULL, 0, NULL, NULL} }; |