Make "net sam [add|del]mem" work for domain groups
authorVolker Lendecke <vl@samba.org>
Tue, 9 Jun 2009 13:23:33 +0000 (15:23 +0200)
committerVolker Lendecke <vl@samba.org>
Tue, 9 Jun 2009 13:25:15 +0000 (15:25 +0200)
source3/utils/net_sam.c

index 1919b40605e2f567536f922cf311faf15568186b..0d8b6ff4821062ca989a7182d656f95064463e64 100644 (file)
@@ -1178,6 +1178,18 @@ static int net_sam_addmem(struct net_context *c, int argc, const char **argv)
                                  "with %s\n", nt_errstr(status));
                        return -1;
                }
+       } else if (grouptype == SID_NAME_DOM_GRP) {
+               uint32_t grouprid, memberrid;
+
+               sid_peek_rid(&group, &grouprid);
+               sid_peek_rid(&member, &memberrid);
+
+               status = pdb_add_groupmem(talloc_tos(), grouprid, memberrid);
+               if (!NT_STATUS_IS_OK(status)) {
+                       d_fprintf(stderr, "Adding domain group member failed "
+                                 "with %s\n", nt_errstr(status));
+                       return -1;
+               }
        } else {
                d_fprintf(stderr, "Can only add members to local groups so "
                          "far, %s is a %s\n", argv[0],
@@ -1233,6 +1245,18 @@ static int net_sam_delmem(struct net_context *c, int argc, const char **argv)
                                  "with %s\n", nt_errstr(status));
                        return -1;
                }
+       } else if (grouptype == SID_NAME_DOM_GRP) {
+               uint32_t grouprid, memberrid;
+
+               sid_peek_rid(&group, &grouprid);
+               sid_peek_rid(&member, &memberrid);
+
+               status = pdb_del_groupmem(talloc_tos(), grouprid, memberrid);
+               if (!NT_STATUS_IS_OK(status)) {
+                       d_fprintf(stderr, "Deleting domain group member "
+                                 "failed with %s\n", nt_errstr(status));
+                       return -1;
+               }
        } else {
                d_fprintf(stderr, "Can only delete members from local groups "
                          "so far, %s is a %s\n", argv[0],