diff options
author | Volker Lendecke <vlendec@samba.org> | 2004-06-02 14:25:29 +0000 |
---|---|---|
committer | Gerald (Jerry) Carter <jerry@samba.org> | 2007-10-10 10:51:52 -0500 |
commit | 47af5445f39202b91e29bce0fff8933e56063789 (patch) | |
tree | 9a8af8fd32bdc6549d83d13fa2a7ff489359927d /source3/utils | |
parent | efc96df3d5b415ca9c19527a44d0619992712b6d (diff) | |
download | samba-47af5445f39202b91e29bce0fff8933e56063789.tar.gz samba-47af5445f39202b91e29bce0fff8933e56063789.tar.bz2 samba-47af5445f39202b91e29bce0fff8933e56063789.zip |
r977: Implement 'net rpc group rename' -- rename domain groups.
Volker
(This used to be commit 9ceff803278bdbc09cb5ab678a108cea24ab49a9)
Diffstat (limited to 'source3/utils')
-rw-r--r-- | source3/utils/net_rpc.c | 78 |
1 files changed, 78 insertions, 0 deletions
diff --git a/source3/utils/net_rpc.c b/source3/utils/net_rpc.c index 41ab5ff8a7..e21f79df30 100644 --- a/source3/utils/net_rpc.c +++ b/source3/utils/net_rpc.c @@ -2209,6 +2209,83 @@ static int rpc_group_members(int argc, const char **argv) argc, argv); } +static NTSTATUS +rpc_group_rename_internals(const DOM_SID *domain_sid, + const char *domain_name, + struct cli_state *cli, + TALLOC_CTX *mem_ctx, int argc, const char **argv) +{ + NTSTATUS result; + POLICY_HND connect_pol, domain_pol, group_pol; + uint32 num_rids, *rids, *rid_types; + GROUP_INFO_CTR ctr; + + if (argc != 2) { + d_printf("Usage: 'net rpc group rename group newname'\n"); + return NT_STATUS_UNSUCCESSFUL; + } + + /* Get sam policy handle */ + + result = cli_samr_connect(cli, mem_ctx, MAXIMUM_ALLOWED_ACCESS, + &connect_pol); + + if (!NT_STATUS_IS_OK(result)) + return result; + + /* Get domain policy handle */ + + result = cli_samr_open_domain(cli, mem_ctx, &connect_pol, + MAXIMUM_ALLOWED_ACCESS, + domain_sid, &domain_pol); + + if (!NT_STATUS_IS_OK(result)) + return result; + + result = cli_samr_lookup_names(cli, mem_ctx, &domain_pol, 1000, + 1, argv, &num_rids, &rids, &rid_types); + + if (num_rids != 1) { + d_printf("Couldn't find group %s\n", argv[0]); + return result; + } + + if (rid_types[0] != SID_NAME_DOM_GRP) { + d_printf("Can only rename domain groups\n"); + return NT_STATUS_UNSUCCESSFUL; + } + + result = cli_samr_open_group(cli, mem_ctx, &domain_pol, + MAXIMUM_ALLOWED_ACCESS, + rids[0], &group_pol); + + if (!NT_STATUS_IS_OK(result)) + return result; + + ZERO_STRUCT(ctr); + + ctr.switch_value1 = 2; + init_samr_group_info2(&ctr.group.info2, argv[1]); + + result = cli_samr_set_groupinfo(cli, mem_ctx, &group_pol, &ctr); + + if (!NT_STATUS_IS_OK(result)) + return result; + + return NT_STATUS_NO_SUCH_GROUP; +} + +static int rpc_group_rename(int argc, const char **argv) +{ + if (argc != 2) { + return rpc_group_usage(argc, argv); + } + + return run_rpc_command(NULL, PI_SAMR, 0, + rpc_group_rename_internals, + argc, argv); +} + /** * 'net rpc group' entrypoint. * @param argc Standard main() style argc @@ -2225,6 +2302,7 @@ int net_rpc_group(int argc, const char **argv) {"delmem", rpc_group_delmem}, {"list", rpc_group_list}, {"members", rpc_group_members}, + {"rename", rpc_group_rename}, {NULL, NULL} }; |