Implement "net sam deletedomaingroup"
authorVolker Lendecke <vl@samba.org>
Tue, 9 Jun 2009 12:46:43 +0000 (14:46 +0200)
committerVolker Lendecke <vl@samba.org>
Tue, 9 Jun 2009 12:49:33 +0000 (14:49 +0200)
source3/utils/net_sam.c

index ddf4d4e16214f992d4acf31a26fa1018d84da618..1919b40605e2f567536f922cf311faf15568186b 100644 (file)
@@ -949,6 +949,51 @@ static int net_sam_createdomaingroup(struct net_context *c, int argc,
        return 0;
 }
 
        return 0;
 }
 
+/*
+ * 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
  */
 /*
  * Create a local group
  */
@@ -1894,6 +1939,14 @@ int net_sam(struct net_context *c, int argc, const char **argv)
                        "net sam deletelocalgroup\n"
                        "    Delete an existing local group"
                },
                        "net sam deletelocalgroup\n"
                        "    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,
                {
                        "mapunixgroup",
                        net_sam_mapunixgroup,