diff options
Diffstat (limited to 'source3/utils/net_sam.c')
-rw-r--r-- | source3/utils/net_sam.c | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/source3/utils/net_sam.c b/source3/utils/net_sam.c index ddf4d4e162..1919b40605 100644 --- a/source3/utils/net_sam.c +++ b/source3/utils/net_sam.c @@ -950,6 +950,51 @@ static int net_sam_createdomaingroup(struct net_context *c, int argc, } /* + * Delete a domain group + */ + +static int net_sam_deletedomaingroup(struct net_context *c, int argc, + const char **argv) +{ + DOM_SID sid; + uint32_t rid; + enum lsa_SidType type; + const char *dom, *name; + NTSTATUS status; + + if (argc != 1 || c->display_usage) { + d_fprintf(stderr, "usage: net sam deletelocalgroup <name>\n"); + return -1; + } + + if (!lookup_name(talloc_tos(), argv[0], LOOKUP_NAME_LOCAL, + &dom, &name, &sid, &type)) { + d_fprintf(stderr, "Could not find %s.\n", argv[0]); + return -1; + } + + if (type != SID_NAME_DOM_GRP) { + d_fprintf(stderr, "%s is a %s, not a domain group.\n", argv[0], + sid_type_lookup(type)); + return -1; + } + + sid_peek_rid(&sid, &rid); + + status = pdb_delete_dom_group(talloc_tos(), rid); + + if (!NT_STATUS_IS_OK(status)) { + d_fprintf(stderr, "Deleting domain group %s failed with %s\n", + argv[0], nt_errstr(status)); + return -1; + } + + d_printf("Deleted domain group %s.\n", argv[0]); + + return 0; +} + +/* * Create a local group */ @@ -1895,6 +1940,14 @@ int net_sam(struct net_context *c, int argc, const char **argv) " Delete an existing local group" }, { + "deletedomaingroup", + net_sam_deletedomaingroup, + NET_TRANSPORT_LOCAL, + "Delete a domain group", + "net sam deletedomaingroup\n" + " Delete a group" + }, + { "mapunixgroup", net_sam_mapunixgroup, NET_TRANSPORT_LOCAL, |