2
* Unix SMB/CIFS implementation.
3
* NetGroupGetInfo 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
uint8_t *buffer = NULL;
38
struct GROUP_INFO_0 *g0;
39
struct GROUP_INFO_1 *g1;
40
struct GROUP_INFO_2 *g2;
41
struct GROUP_INFO_3 *g3;
47
struct poptOption long_options[] = {
49
POPT_COMMON_LIBNETAPI_EXAMPLES
53
status = libnetapi_init(&ctx);
58
pc = poptGetContext("group_getinfo", argc, argv, long_options, 0);
60
poptSetOtherOptionHelp(pc, "hostname groupname level");
61
while((opt = poptGetNextOpt(pc)) != -1) {
64
if (!poptPeekArg(pc)) {
65
poptPrintHelp(pc, stderr, 0);
68
hostname = poptGetArg(pc);
70
if (!poptPeekArg(pc)) {
71
poptPrintHelp(pc, stderr, 0);
74
groupname = poptGetArg(pc);
76
if (poptPeekArg(pc)) {
77
level = atoi(poptGetArg(pc));
82
status = NetGroupGetInfo(hostname,
87
printf("NetGroupGetInfo failed with: %s\n",
88
libnetapi_get_error_string(ctx, status));
94
g0 = (struct GROUP_INFO_0 *)buffer;
95
printf("name: %s\n", g0->grpi0_name);
98
g1 = (struct GROUP_INFO_1 *)buffer;
99
printf("name: %s\n", g1->grpi1_name);
100
printf("comment: %s\n", g1->grpi1_comment);
103
g2 = (struct GROUP_INFO_2 *)buffer;
104
printf("name: %s\n", g2->grpi2_name);
105
printf("comment: %s\n", g2->grpi2_comment);
106
printf("group_id: %d\n", g2->grpi2_group_id);
107
printf("attributes: %d\n", g2->grpi2_attributes);
110
g3 = (struct GROUP_INFO_3 *)buffer;
111
printf("name: %s\n", g3->grpi3_name);
112
printf("comment: %s\n", g3->grpi3_comment);
113
if (ConvertSidToStringSid(g3->grpi3_group_sid,
115
printf("group_sid: %s\n", sid_str);
118
printf("attributes: %d\n", g3->grpi3_attributes);