2 * Unix SMB/CIFS implementation.
3 * NetGroupSetInfo query
4 * Copyright (C) Guenther Deschner 2008
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 3 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, see <http://www.gnu.org/licenses/>.
20 #include <sys/types.h>
30 int main(int argc
, const char **argv
)
32 NET_API_STATUS status
;
33 struct libnetapi_ctx
*ctx
= NULL
;
34 const char *hostname
= NULL
;
35 const char *groupname
= NULL
;
36 const char *option
= NULL
;
37 uint8_t *buffer
= NULL
;
39 uint32_t parm_err
= 0;
40 struct GROUP_INFO_0 g0
;
41 struct GROUP_INFO_1 g1
;
42 struct GROUP_INFO_2 g2
;
43 struct GROUP_INFO_3 g3
;
44 struct GROUP_INFO_1002 g1002
;
45 struct GROUP_INFO_1005 g1005
;
50 struct poptOption long_options
[] = {
52 POPT_COMMON_LIBNETAPI_EXAMPLES
56 status
= libnetapi_init(&ctx
);
61 pc
= poptGetContext("group_setinfo", argc
, argv
, long_options
, 0);
63 poptSetOtherOptionHelp(pc
, "hostname groupname level option");
64 while((opt
= poptGetNextOpt(pc
)) != -1) {
67 if (!poptPeekArg(pc
)) {
68 poptPrintHelp(pc
, stderr
, 0);
71 hostname
= poptGetArg(pc
);
73 if (!poptPeekArg(pc
)) {
74 poptPrintHelp(pc
, stderr
, 0);
77 groupname
= poptGetArg(pc
);
79 if (!poptPeekArg(pc
)) {
80 poptPrintHelp(pc
, stderr
, 0);
83 level
= atoi(poptGetArg(pc
));
85 if (!poptPeekArg(pc
)) {
86 poptPrintHelp(pc
, stderr
, 0);
89 option
= poptGetArg(pc
);
95 g0
.grpi0_name
= option
;
96 buffer
= (uint8_t *)&g0
;
99 g1
.grpi1_name
= option
; /* this one will be ignored */
100 g1
.grpi1_comment
= option
;
101 buffer
= (uint8_t *)&g1
;
104 g2
.grpi2_name
= option
; /* this one will be ignored */
105 g2
.grpi2_comment
= option
;
106 g2
.grpi2_group_id
= 4711; /* this one will be ignored */
107 g2
.grpi2_attributes
= 7;
108 buffer
= (uint8_t *)&g2
;
111 g3
.grpi3_name
= option
; /* this one will be ignored */
112 g3
.grpi3_comment
= option
;
113 g2
.grpi2_attributes
= 7;
114 buffer
= (uint8_t *)&g3
;
117 g1002
.grpi1002_comment
= option
;
118 buffer
= (uint8_t *)&g1002
;
121 g1005
.grpi1005_attributes
= atoi(option
);
122 buffer
= (uint8_t *)&g1005
;
126 status
= NetGroupSetInfo(hostname
,
132 printf("NetGroupSetInfo failed with: %s\n",
133 libnetapi_get_error_string(ctx
, status
));