summaryrefslogtreecommitdiff
path: root/source/lib/netapi/examples/localgroup
diff options
context:
space:
mode:
Diffstat (limited to 'source/lib/netapi/examples/localgroup')
-rw-r--r--source/lib/netapi/examples/localgroup/localgroup_add.c106
-rw-r--r--source/lib/netapi/examples/localgroup/localgroup_addmembers.c141
-rw-r--r--source/lib/netapi/examples/localgroup/localgroup_del.c83
-rw-r--r--source/lib/netapi/examples/localgroup/localgroup_delmembers.c141
-rw-r--r--source/lib/netapi/examples/localgroup/localgroup_enum.c126
-rw-r--r--source/lib/netapi/examples/localgroup/localgroup_getinfo.c112
-rw-r--r--source/lib/netapi/examples/localgroup/localgroup_getmembers.c165
-rw-r--r--source/lib/netapi/examples/localgroup/localgroup_setinfo.c128
-rw-r--r--source/lib/netapi/examples/localgroup/localgroup_setmembers.c146
9 files changed, 0 insertions, 1148 deletions
diff --git a/source/lib/netapi/examples/localgroup/localgroup_add.c b/source/lib/netapi/examples/localgroup/localgroup_add.c
deleted file mode 100644
index 7f23c99db1..0000000000
--- a/source/lib/netapi/examples/localgroup/localgroup_add.c
+++ /dev/null
@@ -1,106 +0,0 @@
-/*
- * Unix SMB/CIFS implementation.
- * NetLocalGroupAdd query
- * Copyright (C) Guenther Deschner 2008
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, see <http://www.gnu.org/licenses/>.
- */
-
-#include <sys/types.h>
-#include <inttypes.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
-#include <netapi.h>
-
-#include "common.h"
-
-int main(int argc, const char **argv)
-{
- NET_API_STATUS status;
- struct libnetapi_ctx *ctx = NULL;
- const char *hostname = NULL;
- const char *groupname = NULL;
- const char *comment = NULL;
- struct LOCALGROUP_INFO_0 g0;
- struct LOCALGROUP_INFO_1 g1;
- uint32_t parm_error = 0;
- uint8_t *buf = NULL;
- uint32_t level = 0;
-
- poptContext pc;
- int opt;
-
- struct poptOption long_options[] = {
- POPT_AUTOHELP
- POPT_COMMON_LIBNETAPI_EXAMPLES
- POPT_TABLEEND
- };
-
- status = libnetapi_init(&ctx);
- if (status != 0) {
- return status;
- }
-
- pc = poptGetContext("localgroup_add", argc, argv, long_options, 0);
-
- poptSetOtherOptionHelp(pc, "hostname groupname comment");
- while((opt = poptGetNextOpt(pc)) != -1) {
- }
-
- if (!poptPeekArg(pc)) {
- poptPrintHelp(pc, stderr, 0);
- goto out;
- }
- hostname = poptGetArg(pc);
-
- if (!poptPeekArg(pc)) {
- poptPrintHelp(pc, stderr, 0);
- goto out;
- }
- groupname = poptGetArg(pc);
-
- if (poptPeekArg(pc)) {
- comment = poptGetArg(pc);
- }
-
- /* NetLocalGroupAdd */
-
- if (comment) {
- level = 1;
- g1.lgrpi1_name = groupname;
- g1.lgrpi1_comment = comment;
- buf = (uint8_t *)&g1;
- } else {
- level = 0;
- g0.lgrpi0_name = groupname;
- buf = (uint8_t *)&g0;
- }
-
- status = NetLocalGroupAdd(hostname,
- level,
- buf,
- &parm_error);
- if (status != 0) {
- printf("NetLocalGroupAdd failed with: %s\n",
- libnetapi_get_error_string(ctx, status));
- }
-
- out:
- libnetapi_free(ctx);
- poptFreeContext(pc);
-
- return status;
-}
diff --git a/source/lib/netapi/examples/localgroup/localgroup_addmembers.c b/source/lib/netapi/examples/localgroup/localgroup_addmembers.c
deleted file mode 100644
index aa4a9b59b0..0000000000
--- a/source/lib/netapi/examples/localgroup/localgroup_addmembers.c
+++ /dev/null
@@ -1,141 +0,0 @@
-/*
- * Unix SMB/CIFS implementation.
- * NetLocalGroupAddMembers query
- * Copyright (C) Guenther Deschner 2008
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, see <http://www.gnu.org/licenses/>.
- */
-
-#include <sys/types.h>
-#include <inttypes.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
-#include <netapi.h>
-
-#include "common.h"
-
-int main(int argc, const char **argv)
-{
- NET_API_STATUS status;
- struct libnetapi_ctx *ctx = NULL;
- const char *hostname = NULL;
- const char *groupname = NULL;
- struct LOCALGROUP_MEMBERS_INFO_0 *g0;
- struct LOCALGROUP_MEMBERS_INFO_3 *g3;
- uint32_t total_entries = 0;
- uint8_t *buffer = NULL;
- uint32_t level = 3;
- const char **names = NULL;
- int i = 0;
-
- poptContext pc;
- int opt;
-
- struct poptOption long_options[] = {
- POPT_AUTOHELP
- POPT_COMMON_LIBNETAPI_EXAMPLES
- POPT_TABLEEND
- };
-
- status = libnetapi_init(&ctx);
- if (status != 0) {
- return status;
- }
-
- pc = poptGetContext("localgroup_addmembers", argc, argv, long_options, 0);
-
- poptSetOtherOptionHelp(pc, "hostname groupname member1 member2 ...");
- while((opt = poptGetNextOpt(pc)) != -1) {
- }
-
- if (!poptPeekArg(pc)) {
- poptPrintHelp(pc, stderr, 0);
- goto out;
- }
- hostname = poptGetArg(pc);
-
- if (!poptPeekArg(pc)) {
- poptPrintHelp(pc, stderr, 0);
- goto out;
- }
- groupname = poptGetArg(pc);
-
- if (!poptPeekArg(pc)) {
- poptPrintHelp(pc, stderr, 0);
- goto out;
- }
-
- names = poptGetArgs(pc);
- for (i=0; names[i] != NULL; i++) {
- total_entries++;
- }
-
- switch (level) {
- case 0:
- status = NetApiBufferAllocate(sizeof(struct LOCALGROUP_MEMBERS_INFO_0) * total_entries,
- (void **)&g0);
- if (status) {
- printf("NetApiBufferAllocate failed with: %s\n",
- libnetapi_get_error_string(ctx, status));
- goto out;
- }
-
- for (i=0; i<total_entries; i++) {
- if (!ConvertStringSidToSid(names[i], &g0[i].lgrmi0_sid)) {
- printf("could not convert sid\n");
- goto out;
- }
- }
-
- buffer = (uint8_t *)g0;
- break;
- case 3:
- status = NetApiBufferAllocate(sizeof(struct LOCALGROUP_MEMBERS_INFO_3) * total_entries,
- (void **)&g3);
- if (status) {
- printf("NetApiBufferAllocate failed with: %s\n",
- libnetapi_get_error_string(ctx, status));
- goto out;
- }
-
- for (i=0; i<total_entries; i++) {
- g3[i].lgrmi3_domainandname = names[i];
- }
-
- buffer = (uint8_t *)g3;
- break;
- default:
- break;
- }
-
- /* NetLocalGroupAddMembers */
-
- status = NetLocalGroupAddMembers(hostname,
- groupname,
- level,
- buffer,
- total_entries);
- if (status != 0) {
- printf("NetLocalGroupAddMembers failed with: %s\n",
- libnetapi_get_error_string(ctx, status));
- }
-
- out:
- libnetapi_free(ctx);
- poptFreeContext(pc);
-
- return status;
-}
diff --git a/source/lib/netapi/examples/localgroup/localgroup_del.c b/source/lib/netapi/examples/localgroup/localgroup_del.c
deleted file mode 100644
index a2515dfdcd..0000000000
--- a/source/lib/netapi/examples/localgroup/localgroup_del.c
+++ /dev/null
@@ -1,83 +0,0 @@
-/*
- * Unix SMB/CIFS implementation.
- * NetLocalGroupDel query
- * Copyright (C) Guenther Deschner 2008
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, see <http://www.gnu.org/licenses/>.
- */
-
-#include <sys/types.h>
-#include <inttypes.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
-#include <netapi.h>
-
-#include "common.h"
-
-int main(int argc, const char **argv)
-{
- NET_API_STATUS status;
- struct libnetapi_ctx *ctx = NULL;
- const char *hostname = NULL;
- const char *groupname = NULL;
-
- poptContext pc;
- int opt;
-
- struct poptOption long_options[] = {
- POPT_AUTOHELP
- POPT_COMMON_LIBNETAPI_EXAMPLES
- POPT_TABLEEND
- };
-
- status = libnetapi_init(&ctx);
- if (status != 0) {
- return status;
- }
-
- pc = poptGetContext("localgroup_del", argc, argv, long_options, 0);
-
- poptSetOtherOptionHelp(pc, "hostname groupname");
- while((opt = poptGetNextOpt(pc)) != -1) {
- }
-
- if (!poptPeekArg(pc)) {
- poptPrintHelp(pc, stderr, 0);
- goto out;
- }
- hostname = poptGetArg(pc);
-
- if (!poptPeekArg(pc)) {
- poptPrintHelp(pc, stderr, 0);
- goto out;
- }
- groupname = poptGetArg(pc);
-
- /* NetLocalGroupDel */
-
- status = NetLocalGroupDel(hostname,
- groupname);
- if (status != 0) {
- printf("NetLocalGroupDel failed with: %s\n",
- libnetapi_get_error_string(ctx, status));
- }
-
- out:
- libnetapi_free(ctx);
- poptFreeContext(pc);
-
- return status;
-}
diff --git a/source/lib/netapi/examples/localgroup/localgroup_delmembers.c b/source/lib/netapi/examples/localgroup/localgroup_delmembers.c
deleted file mode 100644
index 7bd3ec0993..0000000000
--- a/source/lib/netapi/examples/localgroup/localgroup_delmembers.c
+++ /dev/null
@@ -1,141 +0,0 @@
-/*
- * Unix SMB/CIFS implementation.
- * NetLocalGroupDelMembers query
- * Copyright (C) Guenther Deschner 2008
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, see <http://www.gnu.org/licenses/>.
- */
-
-#include <sys/types.h>
-#include <inttypes.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
-#include <netapi.h>
-
-#include "common.h"
-
-int main(int argc, const char **argv)
-{
- NET_API_STATUS status;
- struct libnetapi_ctx *ctx = NULL;
- const char *hostname = NULL;
- const char *groupname = NULL;
- struct LOCALGROUP_MEMBERS_INFO_0 *g0;
- struct LOCALGROUP_MEMBERS_INFO_3 *g3;
- uint32_t total_entries = 0;
- uint8_t *buffer = NULL;
- uint32_t level = 3;
- const char **names = NULL;
- int i = 0;
-
- poptContext pc;
- int opt;
-
- struct poptOption long_options[] = {
- POPT_AUTOHELP
- POPT_COMMON_LIBNETAPI_EXAMPLES
- POPT_TABLEEND
- };
-
- status = libnetapi_init(&ctx);
- if (status != 0) {
- return status;
- }
-
- pc = poptGetContext("localgroup_delmembers", argc, argv, long_options, 0);
-
- poptSetOtherOptionHelp(pc, "hostname groupname member1 member2 ...");
- while((opt = poptGetNextOpt(pc)) != -1) {
- }
-
- if (!poptPeekArg(pc)) {
- poptPrintHelp(pc, stderr, 0);
- goto out;
- }
- hostname = poptGetArg(pc);
-
- if (!poptPeekArg(pc)) {
- poptPrintHelp(pc, stderr, 0);
- goto out;
- }
- groupname = poptGetArg(pc);
-
- if (!poptPeekArg(pc)) {
- poptPrintHelp(pc, stderr, 0);
- goto out;
- }
-
- names = poptGetArgs(pc);
- for (i=0; names[i] != NULL; i++) {
- total_entries++;
- }
-
- switch (level) {
- case 0:
- status = NetApiBufferAllocate(sizeof(struct LOCALGROUP_MEMBERS_INFO_0) * total_entries,
- (void **)&g0);
- if (status) {
- printf("NetApiBufferAllocate failed with: %s\n",
- libnetapi_get_error_string(ctx, status));
- goto out;
- }
-
- for (i=0; i<total_entries; i++) {
- if (!ConvertStringSidToSid(names[i], &g0[i].lgrmi0_sid)) {
- printf("could not convert sid\n");
- goto out;
- }
- }
-
- buffer = (uint8_t *)g0;
- break;
- case 3:
- status = NetApiBufferAllocate(sizeof(struct LOCALGROUP_MEMBERS_INFO_3) * total_entries,
- (void **)&g3);
- if (status) {
- printf("NetApiBufferAllocate failed with: %s\n",
- libnetapi_get_error_string(ctx, status));
- goto out;
- }
-
- for (i=0; i<total_entries; i++) {
- g3[i].lgrmi3_domainandname = names[i];
- }
-
- buffer = (uint8_t *)g3;
- break;
- default:
- break;
- }
-
- /* NetLocalGroupDelMembers */
-
- status = NetLocalGroupDelMembers(hostname,
- groupname,
- level,
- buffer,
- total_entries);
- if (status != 0) {
- printf("NetLocalGroupDelMembers failed with: %s\n",
- libnetapi_get_error_string(ctx, status));
- }
-
- out:
- libnetapi_free(ctx);
- poptFreeContext(pc);
-
- return status;
-}
diff --git a/source/lib/netapi/examples/localgroup/localgroup_enum.c b/source/lib/netapi/examples/localgroup/localgroup_enum.c
deleted file mode 100644
index 6fe0cf4173..0000000000
--- a/source/lib/netapi/examples/localgroup/localgroup_enum.c
+++ /dev/null
@@ -1,126 +0,0 @@
-/*
- * Unix SMB/CIFS implementation.
- * NetLocalGroupEnum query
- * Copyright (C) Guenther Deschner 2008
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, see <http://www.gnu.org/licenses/>.
- */
-
-#include <sys/types.h>
-#include <inttypes.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
-#include <netapi.h>
-
-#include "common.h"
-
-int main(int argc, const char **argv)
-{
- NET_API_STATUS status;
- struct libnetapi_ctx *ctx = NULL;
- const char *hostname = NULL;
- uint32_t level = 0;
- uint8_t *buffer = NULL;
- uint32_t entries_read = 0;
- uint32_t total_entries = 0;
- uint32_t resume_handle = 0;
- int i;
-
- struct LOCALGROUP_INFO_0 *info0 = NULL;
- struct LOCALGROUP_INFO_1 *info1 = NULL;
-
- poptContext pc;
- int opt;
-
- struct poptOption long_options[] = {
- POPT_AUTOHELP
- POPT_COMMON_LIBNETAPI_EXAMPLES
- POPT_TABLEEND
- };
-
- status = libnetapi_init(&ctx);
- if (status != 0) {
- return status;
- }
-
- pc = poptGetContext("localgroup_enum", argc, argv, long_options, 0);
-
- poptSetOtherOptionHelp(pc, "hostname level");
- while((opt = poptGetNextOpt(pc)) != -1) {
- }
-
- if (!poptPeekArg(pc)) {
- poptPrintHelp(pc, stderr, 0);
- goto out;
- }
- hostname = poptGetArg(pc);
-
- if (poptPeekArg(pc)) {
- level = atoi(poptGetArg(pc));
- }
-
- /* NetLocalGroupEnum */
-
- do {
- status = NetLocalGroupEnum(hostname,
- level,
- &buffer,
- (uint32_t)-1,
- &entries_read,
- &total_entries,
- &resume_handle);
- if (status == 0 || status == ERROR_MORE_DATA) {
- printf("total entries: %d\n", total_entries);
- switch (level) {
- case 0:
- info0 = (struct LOCALGROUP_INFO_0 *)buffer;
- break;
- case 1:
- info1 = (struct LOCALGROUP_INFO_1 *)buffer;
- break;
- default:
- break;
- }
- for (i=0; i<entries_read; i++) {
- switch (level) {
- case 0:
- printf("#%d group: %s\n", i, info0->lgrpi0_name);
- info0++;
- break;
- case 1:
- printf("#%d group: %s\n", i, info1->lgrpi1_name);
- printf("#%d comment: %s\n", i, info1->lgrpi1_comment);
- info1++;
- break;
- default:
- break;
- }
- }
- NetApiBufferFree(buffer);
- }
- } while (status == ERROR_MORE_DATA);
-
- if (status != 0) {
- printf("NetLocalGroupEnum failed with: %s\n",
- libnetapi_get_error_string(ctx, status));
- }
-
- out:
- libnetapi_free(ctx);
- poptFreeContext(pc);
-
- return status;
-}
diff --git a/source/lib/netapi/examples/localgroup/localgroup_getinfo.c b/source/lib/netapi/examples/localgroup/localgroup_getinfo.c
deleted file mode 100644
index cd8fa8c3b3..0000000000
--- a/source/lib/netapi/examples/localgroup/localgroup_getinfo.c
+++ /dev/null
@@ -1,112 +0,0 @@
-/*
- * Unix SMB/CIFS implementation.
- * NetLocalGroupGetInfo query
- * Copyright (C) Guenther Deschner 2008
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, see <http://www.gnu.org/licenses/>.
- */
-
-#include <sys/types.h>
-#include <inttypes.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
-#include <netapi.h>
-
-#include "common.h"
-
-int main(int argc, const char **argv)
-{
- NET_API_STATUS status;
- struct libnetapi_ctx *ctx = NULL;
- const char *hostname = NULL;
- const char *groupname = NULL;
- uint8_t *buffer = NULL;
- uint32_t level = 0;
- struct LOCALGROUP_INFO_0 *g0;
- struct LOCALGROUP_INFO_1 *g1;
- struct LOCALGROUP_INFO_1002 *g1002;
-
- poptContext pc;
- int opt;
-
- struct poptOption long_options[] = {
- POPT_AUTOHELP
- POPT_COMMON_LIBNETAPI_EXAMPLES
- POPT_TABLEEND
- };
-
- status = libnetapi_init(&ctx);
- if (status != 0) {
- return status;
- }
-
- pc = poptGetContext("localgroup_getinfo", argc, argv, long_options, 0);
-
- poptSetOtherOptionHelp(pc, "hostname groupname level");
- while((opt = poptGetNextOpt(pc)) != -1) {
- }
-
- if (!poptPeekArg(pc)) {
- poptPrintHelp(pc, stderr, 0);
- goto out;
- }
- hostname = poptGetArg(pc);
-
- if (!poptPeekArg(pc)) {
- poptPrintHelp(pc, stderr, 0);
- goto out;
- }
- groupname = poptGetArg(pc);
-
- if (poptPeekArg(pc)) {
- level = atoi(poptGetArg(pc));
- }
-
- /* NetLocalGroupGetInfo */
-
- status = NetLocalGroupGetInfo(hostname,
- groupname,
- level,
- &buffer);
- if (status != 0) {
- printf("NetLocalGroupGetInfo failed with: %s\n",
- libnetapi_get_error_string(ctx, status));
- goto out;
- }
-
- switch (level) {
- case 0:
- g0 = (struct LOCALGROUP_INFO_0 *)buffer;
- printf("name: %s\n", g0->lgrpi0_name);
- break;
- case 1:
- g1 = (struct LOCALGROUP_INFO_1 *)buffer;
- printf("name: %s\n", g1->lgrpi1_name);
- printf("comment: %s\n", g1->lgrpi1_comment);
- break;
- case 1002:
- g1002 = (struct LOCALGROUP_INFO_1002 *)buffer;
- printf("comment: %s\n", g1002->lgrpi1002_comment);
- break;
- }
- NetApiBufferFree(buffer);
-
- out:
- libnetapi_free(ctx);
- poptFreeContext(pc);
-
- return status;
-}
diff --git a/source/lib/netapi/examples/localgroup/localgroup_getmembers.c b/source/lib/netapi/examples/localgroup/localgroup_getmembers.c
deleted file mode 100644
index 0589870d02..0000000000
--- a/source/lib/netapi/examples/localgroup/localgroup_getmembers.c
+++ /dev/null
@@ -1,165 +0,0 @@
-/*
- * Unix SMB/CIFS implementation.
- * NetLocalGroupGetMembers query
- * Copyright (C) Guenther Deschner 2008
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, see <http://www.gnu.org/licenses/>.
- */
-
-#include <sys/types.h>
-#include <inttypes.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
-#include <netapi.h>
-
-#include "common.h"
-
-int main(int argc, const char **argv)
-{
- NET_API_STATUS status;
- struct libnetapi_ctx *ctx = NULL;
- const char *hostname = NULL;
- const char *groupname = NULL;
- uint32_t level = 0;
- uint8_t *buffer = NULL;
- uint32_t entries_read = 0;
- uint32_t total_entries = 0;
- uint32_t resume_handle = 0;
- char *sid_str = NULL;
- int i;
-
- struct LOCALGROUP_MEMBERS_INFO_0 *info0 = NULL;
- struct LOCALGROUP_MEMBERS_INFO_1 *info1 = NULL;
- struct LOCALGROUP_MEMBERS_INFO_2 *info2 = NULL;
- struct LOCALGROUP_MEMBERS_INFO_3 *info3 = NULL;
-
- poptContext pc;
- int opt;
-
- struct poptOption long_options[] = {
- POPT_AUTOHELP
- POPT_COMMON_LIBNETAPI_EXAMPLES
- POPT_TABLEEND
- };
-
- status = libnetapi_init(&ctx);
- if (status != 0) {
- return status;
- }
-
- pc = poptGetContext("localgroup_getmembers", argc, argv, long_options, 0);
-
- poptSetOtherOptionHelp(pc, "hostname groupname level");
- while((opt = poptGetNextOpt(pc)) != -1) {
- }
-
- if (!poptPeekArg(pc)) {
- poptPrintHelp(pc, stderr, 0);
- goto out;
- }
- hostname = poptGetArg(pc);
- if (!poptPeekArg(pc)) {
- poptPrintHelp(pc, stderr, 0);
- goto out;
- }
- groupname = poptGetArg(pc);
-
- if (poptPeekArg(pc)) {
- level = atoi(poptGetArg(pc));
- }
-
- /* NetLocalGroupGetMembers */
-
- do {
- status = NetLocalGroupGetMembers(hostname,
- groupname,
- level,
- &buffer,
- (uint32_t)-1,
- &entries_read,
- &total_entries,
- &resume_handle);
- if (status == 0 || status == ERROR_MORE_DATA) {
- printf("total entries: %d\n", total_entries);
- switch (level) {
- case 0:
- info0 = (struct LOCALGROUP_MEMBERS_INFO_0 *)buffer;
- break;
- case 1:
- info1 = (struct LOCALGROUP_MEMBERS_INFO_1 *)buffer;
- break;
- case 2:
- info2 = (struct LOCALGROUP_MEMBERS_INFO_2 *)buffer;
- break;
- case 3:
- info3 = (struct LOCALGROUP_MEMBERS_INFO_3 *)buffer;
- break;
- default:
- break;
- }
- for (i=0; i<entries_read; i++) {
- switch (level) {
- case 0:
- if (ConvertSidToStringSid(info0->lgrmi0_sid,
- &sid_str)) {
- printf("#%d member sid: %s\n", i, sid_str);
- free(sid_str);
- }
- info0++;
- break;
- case 1:
- if (ConvertSidToStringSid(info1->lgrmi1_sid,
- &sid_str)) {
- printf("#%d member sid: %s\n", i, sid_str);
- free(sid_str);
- }
- printf("#%d sid type: %d\n", i, info1->lgrmi1_sidusage);
- printf("#%d name: %s\n", i, info1->lgrmi1_name);
- info1++;
- break;
- case 2:
- if (ConvertSidToStringSid(info2->lgrmi2_sid,
- &sid_str)) {
- printf("#%d member sid: %s\n", i, sid_str);
- free(sid_str);
- }
- printf("#%d sid type: %d\n", i, info2->lgrmi2_sidusage);
- printf("#%d full name: %s\n", i, info2->lgrmi2_domainandname);
- info2++;
- break;
- case 3:
- printf("#%d full name: %s\n", i, info3->lgrmi3_domainandname);
- info3++;
- break;
- default:
- break;
- }
- }
- NetApiBufferFree(buffer);
- }
- } while (status == ERROR_MORE_DATA);
-
- if (status != 0) {
- printf("NetLocalGroupGetMembers failed with: %s\n",
- libnetapi_get_error_string(ctx, status));
- }
-
- out:
- libnetapi_free(ctx);
- poptFreeContext(pc);
-
- return status;
-}
diff --git a/source/lib/netapi/examples/localgroup/localgroup_setinfo.c b/source/lib/netapi/examples/localgroup/localgroup_setinfo.c
deleted file mode 100644
index efcec76786..0000000000
--- a/source/lib/netapi/examples/localgroup/localgroup_setinfo.c
+++ /dev/null
@@ -1,128 +0,0 @@
-/*
- * Unix SMB/CIFS implementation.
- * NetLocalGroupSetInfo query
- * Copyright (C) Guenther Deschner 2008
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, see <http://www.gnu.org/licenses/>.
- */
-
-#include <sys/types.h>
-#include <inttypes.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
-#include <netapi.h>
-
-#include "common.h"
-
-int main(int argc, const char **argv)
-{
- NET_API_STATUS status;
- struct libnetapi_ctx *ctx = NULL;
- const char *hostname = NULL;
- const char *groupname = NULL;
- uint8_t *buffer = NULL;
- uint32_t level = 0;
- struct LOCALGROUP_INFO_0 g0;
- struct LOCALGROUP_INFO_1 g1;
- struct LOCALGROUP_INFO_1002 g1002;
- const char *newname = NULL;
- const char *newcomment = NULL;
- uint32_t parm_err = 0;
-
- poptContext pc;
- int opt;
-
- struct poptOption long_options[] = {
- POPT_AUTOHELP
- POPT_COMMON_LIBNETAPI_EXAMPLES
- { "newname", 0, POPT_ARG_STRING, NULL, 'n', "New Local Group Name", "NEWNAME" },
- { "newcomment", 0, POPT_ARG_STRING, NULL, 'c', "New Local Group Comment", "NETCOMMENT" },
- POPT_TABLEEND
- };
-
- status = libnetapi_init(&ctx);
- if (status != 0) {
- return status;
- }
-
- pc = poptGetContext("localgroup_setinfo", argc, argv, long_options, 0);
-
- poptSetOtherOptionHelp(pc, "hostname groupname level");
- while((opt = poptGetNextOpt(pc)) != -1) {
- switch (opt) {
- case 'n':
- newname = poptGetOptArg(pc);
- break;
- case 'c':
- newcomment = poptGetOptArg(pc);
- break;
- }
-
- }
-
- if (!poptPeekArg(pc)) {
- poptPrintHelp(pc, stderr, 0);
- goto out;
- }
- hostname = poptGetArg(pc);
-
- if (!poptPeekArg(pc)) {
- poptPrintHelp(pc, stderr, 0);
- goto out;
- }
- groupname = poptGetArg(pc);
-
- if (poptPeekArg(pc)) {
- level = atoi(poptGetArg(pc));
- }
-
- if (newname && !newcomment) {
- g0.lgrpi0_name = newname;
- buffer = (uint8_t *)&g0;
- level = 0;
- } else if (newcomment && !newname) {
- g1002.lgrpi1002_comment = newcomment;
- buffer = (uint8_t *)&g1002;
- level = 1002;
- } else if (newname && newcomment) {
- g1.lgrpi1_name = newname;
- g1.lgrpi1_comment = newcomment;
- buffer = (uint8_t *)&g1;
- level = 1;
- } else {
- printf("not enough input\n");
- goto out;
- }
-
- /* NetLocalGroupSetInfo */
-
- status = NetLocalGroupSetInfo(hostname,
- groupname,
- level,
- buffer,
- &parm_err);
- if (status != 0) {
- printf("NetLocalGroupSetInfo failed with: %s\n",
- libnetapi_get_error_string(ctx, status));
- goto out;
- }
-
- out:
- libnetapi_free(ctx);
- poptFreeContext(pc);
-
- return status;
-}
diff --git a/source/lib/netapi/examples/localgroup/localgroup_setmembers.c b/source/lib/netapi/examples/localgroup/localgroup_setmembers.c
deleted file mode 100644
index c35f2bbb81..0000000000
--- a/source/lib/netapi/examples/localgroup/localgroup_setmembers.c
+++ /dev/null
@@ -1,146 +0,0 @@
-/*
- * Unix SMB/CIFS implementation.
- * NetLocalGroupSetMembers query
- * Copyright (C) Guenther Deschner 2008
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, see <http://www.gnu.org/licenses/>.
- */
-
-#include <sys/types.h>
-#include <inttypes.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
-#include <netapi.h>
-
-#include "common.h"
-
-int main(int argc, const char **argv)
-{
- NET_API_STATUS status;
- struct libnetapi_ctx *ctx = NULL;
- const char *hostname = NULL;
- const char *groupname = NULL;
- struct LOCALGROUP_MEMBERS_INFO_0 *g0;
- struct LOCALGROUP_MEMBERS_INFO_3 *g3;
- uint32_t total_entries = 0;
- uint8_t *buffer = NULL;
- uint32_t level = 3;
- const char **names = NULL;
- int i = 0;
- size_t buf_size = 0;
-
- poptContext pc;
- int opt;
-
- struct poptOption long_options[] = {
- POPT_AUTOHELP
- POPT_COMMON_LIBNETAPI_EXAMPLES
- POPT_TABLEEND
- };
-
- status = libnetapi_init(&ctx);
- if (status != 0) {
- return status;
- }
-
- pc = poptGetContext("localgroup_setmembers", argc, argv, long_options, 0);
-
- poptSetOtherOptionHelp(pc, "hostname groupname member1 member2 ...");
- while((opt = poptGetNextOpt(pc)) != -1) {
- }
-
- if (!poptPeekArg(pc)) {
- poptPrintHelp(pc, stderr, 0);
- goto out;
- }
- hostname = poptGetArg(pc);
-
- if (!poptPeekArg(pc)) {
- poptPrintHelp(pc, stderr, 0);
- goto out;
- }
- groupname = poptGetArg(pc);
-
- if (!poptPeekArg(pc)) {
- poptPrintHelp(pc, stderr, 0);
- goto out;
- }
-
- names = poptGetArgs(pc);
- for (i=0; names[i] != NULL; i++) {
- total_entries++;
- }
-
- switch (level) {
- case 0:
- buf_size = sizeof(struct LOCALGROUP_MEMBERS_INFO_0) * total_entries;
-
- status = NetApiBufferAllocate(buf_size, (void **)&g0);
- if (status) {
- printf("NetApiBufferAllocate failed with: %s\n",
- libnetapi_get_error_string(ctx, status));
- goto out;
- }
-
- for (i=0; i<total_entries; i++) {
- if (!ConvertStringSidToSid(names[i], &g0[i].lgrmi0_sid)) {
- printf("could not convert sid\n");
- goto out;
- }
- }
-
- buffer = (uint8_t *)g0;
- break;
- case 3:
- buf_size = sizeof(struct LOCALGROUP_MEMBERS_INFO_3) * total_entries;
-
- status = NetApiBufferAllocate(buf_size, (void **)&g3);
- if (status) {
- printf("NetApiBufferAllocate failed with: %s\n",
- libnetapi_get_error_string(ctx, status));
- goto out;
- }
-
- for (i=0; i<total_entries; i++) {
- g3[i].lgrmi3_domainandname = names[i];
- }
-
- buffer = (uint8_t *)g3;
- break;
- default:
- break;
- }
-
- /* NetLocalGroupSetMembers */
-
- status = NetLocalGroupSetMembers(hostname,
- groupname,
- level,
- buffer,
- total_entries);
- if (status != 0) {
- printf("NetLocalGroupSetMembers failed with: %s\n",
- libnetapi_get_error_string(ctx, status));
- }
-
- NetApiBufferFree(buffer);
-
- out:
- libnetapi_free(ctx);
- poptFreeContext(pc);
-
- return status;
-}