diff options
author | Volker Lendecke <vlendec@samba.org> | 2004-02-24 18:03:19 +0000 |
---|---|---|
committer | Volker Lendecke <vlendec@samba.org> | 2004-02-24 18:03:19 +0000 |
commit | c09049d25b22d843524ba54ceeb69295487b2de6 (patch) | |
tree | 5ee3343411f451c86661efd69d74407dbb7ea653 /source3/utils | |
parent | ce789de6e1aa8c8e024edbb0ad4c3411cb0649ef (diff) | |
download | samba-c09049d25b22d843524ba54ceeb69295487b2de6.tar.gz samba-c09049d25b22d843524ba54ceeb69295487b2de6.tar.bz2 samba-c09049d25b22d843524ba54ceeb69295487b2de6.zip |
Add 'net rpc group add'. For this parse_samr.c had to be changed: The
group_info4 in set_dom_group_info also has the level in the record
itself. This seems not to be an align. Tested with NT4 usrmgr.exe. It can
still create a domain group on a samba machine.
Volker
(This used to be commit 9cadd14aa53d390a2419d7ce4fe48d58cf372279)
Diffstat (limited to 'source3/utils')
-rw-r--r-- | source3/utils/net_rpc.c | 63 |
1 files changed, 62 insertions, 1 deletions
diff --git a/source3/utils/net_rpc.c b/source3/utils/net_rpc.c index de6c8be900..e46dfe7fd4 100644 --- a/source3/utils/net_rpc.c +++ b/source3/utils/net_rpc.c @@ -1044,6 +1044,67 @@ static int rpc_group_usage(int argc, const char **argv) return net_help_group(argc, argv); } +static NTSTATUS +rpc_group_add_internals(const DOM_SID *domain_sid, const char *domain_name, + struct cli_state *cli, + TALLOC_CTX *mem_ctx, int argc, const char **argv) +{ + POLICY_HND connect_pol, domain_pol, group_pol; + NTSTATUS result = NT_STATUS_UNSUCCESSFUL; + GROUP_INFO_CTR group_info; + + if (argc != 1) { + d_printf("Group name must be specified\n"); + rpc_group_usage(argc, argv); + return NT_STATUS_OK; + } + + /* Get sam policy handle */ + + result = cli_samr_connect(cli, mem_ctx, MAXIMUM_ALLOWED_ACCESS, + &connect_pol); + if (!NT_STATUS_IS_OK(result)) goto done; + + /* 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)) goto done; + + /* Create the group */ + + result = cli_samr_create_dom_group(cli, mem_ctx, &domain_pol, + argv[0], MAXIMUM_ALLOWED_ACCESS, + &group_pol); + if (!NT_STATUS_IS_OK(result)) goto done; + + if (strlen(opt_comment) == 0) goto done; + + /* We've got a comment to set */ + + group_info.switch_value1 = 4; + init_samr_group_info4(&group_info.group.info4, opt_comment); + + result = cli_samr_set_groupinfo(cli, mem_ctx, &group_pol, &group_info); + if (!NT_STATUS_IS_OK(result)) goto done; + + done: + if (NT_STATUS_IS_OK(result)) + DEBUG(5, ("add group succeeded\n")); + else + d_printf("add group failed: %s\n", nt_errstr(result)); + + return result; +} + +static int rpc_group_add(int argc, const char **argv) +{ + return run_rpc_command(NULL, PI_SAMR, 0, + rpc_group_add_internals, + argc, argv); +} + /** * List groups on a remote RPC server * @@ -1498,8 +1559,8 @@ static int rpc_group_members(int argc, const char **argv) int net_rpc_group(int argc, const char **argv) { struct functable func[] = { -#if 0 {"add", rpc_group_add}, +#if 0 {"delete", rpc_group_delete}, #endif {"list", rpc_group_list}, |