The branch, v3-devel has been updated via afdd14c26c27c9fa245165985a5d8e644855c4b5 (commit) via e28c332f32c4f7b1ac493f69f17254185d9cee96 (commit) via 39a42380ca3fac92eb27bded90ab06f7760937b9 (commit) via b66cee247fa7ef5293074b191b9cc2cbf4eef5f3 (commit) via 03a7f7f33370d65493a81ccead2038ee3ab291d0 (commit) via 038ec4d73a04e53c1cc0a1fa6a830d1032dee489 (commit) via 8a5b0b639240c829cb5bde1bed1707b3ea4ac480 (commit) from 8d541a3579637bb48c04ebb2b18844509c1f43e8 (commit)
http://gitweb.samba.org/?p=samba.git;a=shortlog;h=v3-devel - Log ----------------------------------------------------------------- commit afdd14c26c27c9fa245165985a5d8e644855c4b5 Author: Günther Deschner <[EMAIL PROTECTED]> Date: Tue Sep 2 13:24:51 2008 +0200 netapi: move join related examples to one directory. Guenther commit e28c332f32c4f7b1ac493f69f17254185d9cee96 Author: Günther Deschner <[EMAIL PROTECTED]> Date: Tue Sep 2 13:18:32 2008 +0200 netapi: add NetRenameMachineInDomain example code. Guenther commit 39a42380ca3fac92eb27bded90ab06f7760937b9 Author: Günther Deschner <[EMAIL PROTECTED]> Date: Tue Sep 2 13:17:57 2008 +0200 netapi: implement NetRenameMachineInDomain_r. Guenther commit b66cee247fa7ef5293074b191b9cc2cbf4eef5f3 Author: Günther Deschner <[EMAIL PROTECTED]> Date: Tue Sep 2 11:06:22 2008 +0200 netapi: add NetRenameMachineInDomain to public header. Guenther commit 03a7f7f33370d65493a81ccead2038ee3ab291d0 Author: Günther Deschner <[EMAIL PROTECTED]> Date: Tue Sep 2 11:02:43 2008 +0200 netapi: add skeleton for NetRenameMachineInDomain. Guenther commit 038ec4d73a04e53c1cc0a1fa6a830d1032dee489 Author: Günther Deschner <[EMAIL PROTECTED]> Date: Tue Sep 2 10:59:44 2008 +0200 re-run make idl. Guenther commit 8a5b0b639240c829cb5bde1bed1707b3ea4ac480 Author: Günther Deschner <[EMAIL PROTECTED]> Date: Tue Sep 2 10:58:54 2008 +0200 netapi: add NetRenameMachineInDomain to IDL. Guenther ----------------------------------------------------------------------- Summary of changes: source/lib/netapi/examples/Makefile.in | 10 ++- .../examples/getjoinableous/getjoinableous.c | 95 ------------------ source/lib/netapi/examples/join/getjoinableous.c | 95 ++++++++++++++++++ source/lib/netapi/examples/join/netdomjoin.c | 104 ++++++++++++++++++++ source/lib/netapi/examples/join/rename_machine.c | 86 ++++++++++++++++ source/lib/netapi/examples/netdomjoin/netdomjoin.c | 104 -------------------- source/lib/netapi/joindomain.c | 52 ++++++++++ source/lib/netapi/libnetapi.c | 48 +++++++++ source/lib/netapi/libnetapi.h | 9 ++ source/lib/netapi/netapi.h | 23 +++++ source/librpc/gen_ndr/libnetapi.h | 16 +++ source/librpc/gen_ndr/ndr_libnetapi.c | 26 +++++ source/librpc/gen_ndr/ndr_libnetapi.h | 79 ++++++++------- source/librpc/idl/libnetapi.idl | 12 +++ 14 files changed, 521 insertions(+), 238 deletions(-) delete mode 100644 source/lib/netapi/examples/getjoinableous/getjoinableous.c create mode 100644 source/lib/netapi/examples/join/getjoinableous.c create mode 100644 source/lib/netapi/examples/join/netdomjoin.c create mode 100644 source/lib/netapi/examples/join/rename_machine.c delete mode 100644 source/lib/netapi/examples/netdomjoin/netdomjoin.c Changeset truncated at 500 lines: diff --git a/source/lib/netapi/examples/Makefile.in b/source/lib/netapi/examples/Makefile.in index 169736c..ee72a95 100644 --- a/source/lib/netapi/examples/Makefile.in +++ b/source/lib/netapi/examples/Makefile.in @@ -22,6 +22,7 @@ PROGS = bin/[EMAIL PROTECTED]@ \ bin/[EMAIL PROTECTED]@ \ bin/[EMAIL PROTECTED]@ \ bin/[EMAIL PROTECTED]@ \ + bin/[EMAIL PROTECTED]@ \ bin/[EMAIL PROTECTED]@ \ bin/[EMAIL PROTECTED]@ \ bin/[EMAIL PROTECTED]@ \ @@ -84,9 +85,10 @@ bin/.dummy: CMDLINE_OBJ = common.o GETDC_OBJ = getdc/getdc.o $(CMDLINE_OBJ) DSGETDC_OBJ = dsgetdc/dsgetdc.o $(CMDLINE_OBJ) -NETDOMJOIN_OBJ = netdomjoin/netdomjoin.o $(CMDLINE_OBJ) +NETDOMJOIN_OBJ = join/netdomjoin.o $(CMDLINE_OBJ) NETDOMJOIN_GUI_OBJ = netdomjoin-gui/netdomjoin-gui.o -GETJOINABLEOUS_OBJ = getjoinableous/getjoinableous.o $(CMDLINE_OBJ) +GETJOINABLEOUS_OBJ = join/getjoinableous.o $(CMDLINE_OBJ) +RENAMEMACHINE_OBJ = join/rename_machine.o $(CMDLINE_OBJ) USERADD_OBJ = user/user_add.o $(CMDLINE_OBJ) USERDEL_OBJ = user/user_del.o $(CMDLINE_OBJ) USERENUM_OBJ = user/user_enum.o $(CMDLINE_OBJ) @@ -132,6 +134,10 @@ bin/[EMAIL PROTECTED]@: $(BINARY_PREREQS) $(GETJOINABLEOUS_OBJ) @echo Linking $@ @$(CC) $(FLAGS) -o $@ $(GETJOINABLEOUS_OBJ) $(LDFLAGS) $(DYNEXP) $(CMDLINE_LIBS) +bin/[EMAIL PROTECTED]@: $(BINARY_PREREQS) $(RENAMEMACHINE_OBJ) + @echo Linking $@ + @$(CC) $(FLAGS) -o $@ $(RENAMEMACHINE_OBJ) $(LDFLAGS) $(DYNEXP) $(CMDLINE_LIBS) + bin/[EMAIL PROTECTED]@: $(BINARY_PREREQS) $(NETDOMJOIN_OBJ) @echo Linking $@ @$(CC) $(FLAGS) -o $@ $(NETDOMJOIN_OBJ) $(LDFLAGS) $(DYNEXP) $(CMDLINE_LIBS) diff --git a/source/lib/netapi/examples/getjoinableous/getjoinableous.c b/source/lib/netapi/examples/getjoinableous/getjoinableous.c deleted file mode 100644 index 732f73d..0000000 --- a/source/lib/netapi/examples/getjoinableous/getjoinableous.c +++ /dev/null @@ -1,95 +0,0 @@ -/* - * Unix SMB/CIFS implementation. - * Join Support (cmdline + netapi) - * 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 <string.h> -#include <stdio.h> -#include <sys/types.h> -#include <inttypes.h> - -#include <netapi.h> - -#include "common.h" - -int main(int argc, const char **argv) -{ - NET_API_STATUS status; - const char *host_name = NULL; - const char *domain_name = NULL; - const char **ous = NULL; - uint32_t num_ous = 0; - struct libnetapi_ctx *ctx = NULL; - int i; - - poptContext pc; - int opt; - - struct poptOption long_options[] = { - POPT_AUTOHELP - { "domain", 0, POPT_ARG_STRING, NULL, 'D', "Domain name", "DOMAIN" }, - POPT_COMMON_LIBNETAPI_EXAMPLES - POPT_TABLEEND - }; - - status = libnetapi_init(&ctx); - if (status != 0) { - return status; - } - - pc = poptGetContext("getjoinableous", argc, argv, long_options, 0); - - poptSetOtherOptionHelp(pc, "hostname domainname"); - while((opt = poptGetNextOpt(pc)) != -1) { - switch (opt) { - case 'D': - domain_name = poptGetOptArg(pc); - break; - } - } - - if (!poptPeekArg(pc)) { - poptPrintHelp(pc, stderr, 0); - goto out; - } - host_name = poptGetArg(pc); - - /* NetGetJoinableOUs */ - - status = NetGetJoinableOUs(host_name, - domain_name, - ctx->username, - ctx->password, - &num_ous, - &ous); - if (status != 0) { - printf("failed with: %s\n", - libnetapi_get_error_string(ctx, status)); - } else { - printf("Successfully queried joinable ous:\n"); - for (i=0; i<num_ous; i++) { - printf("ou: %s\n", ous[i]); - } - } - - out: - NetApiBufferFree(ous); - libnetapi_free(ctx); - poptFreeContext(pc); - - return status; -} diff --git a/source/lib/netapi/examples/join/getjoinableous.c b/source/lib/netapi/examples/join/getjoinableous.c new file mode 100644 index 0000000..732f73d --- /dev/null +++ b/source/lib/netapi/examples/join/getjoinableous.c @@ -0,0 +1,95 @@ +/* + * Unix SMB/CIFS implementation. + * Join Support (cmdline + netapi) + * 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 <string.h> +#include <stdio.h> +#include <sys/types.h> +#include <inttypes.h> + +#include <netapi.h> + +#include "common.h" + +int main(int argc, const char **argv) +{ + NET_API_STATUS status; + const char *host_name = NULL; + const char *domain_name = NULL; + const char **ous = NULL; + uint32_t num_ous = 0; + struct libnetapi_ctx *ctx = NULL; + int i; + + poptContext pc; + int opt; + + struct poptOption long_options[] = { + POPT_AUTOHELP + { "domain", 0, POPT_ARG_STRING, NULL, 'D', "Domain name", "DOMAIN" }, + POPT_COMMON_LIBNETAPI_EXAMPLES + POPT_TABLEEND + }; + + status = libnetapi_init(&ctx); + if (status != 0) { + return status; + } + + pc = poptGetContext("getjoinableous", argc, argv, long_options, 0); + + poptSetOtherOptionHelp(pc, "hostname domainname"); + while((opt = poptGetNextOpt(pc)) != -1) { + switch (opt) { + case 'D': + domain_name = poptGetOptArg(pc); + break; + } + } + + if (!poptPeekArg(pc)) { + poptPrintHelp(pc, stderr, 0); + goto out; + } + host_name = poptGetArg(pc); + + /* NetGetJoinableOUs */ + + status = NetGetJoinableOUs(host_name, + domain_name, + ctx->username, + ctx->password, + &num_ous, + &ous); + if (status != 0) { + printf("failed with: %s\n", + libnetapi_get_error_string(ctx, status)); + } else { + printf("Successfully queried joinable ous:\n"); + for (i=0; i<num_ous; i++) { + printf("ou: %s\n", ous[i]); + } + } + + out: + NetApiBufferFree(ous); + libnetapi_free(ctx); + poptFreeContext(pc); + + return status; +} diff --git a/source/lib/netapi/examples/join/netdomjoin.c b/source/lib/netapi/examples/join/netdomjoin.c new file mode 100644 index 0000000..08ce71b --- /dev/null +++ b/source/lib/netapi/examples/join/netdomjoin.c @@ -0,0 +1,104 @@ +/* + * Unix SMB/CIFS implementation. + * Join Support (cmdline + netapi) + * Copyright (C) Guenther Deschner 2007-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" + +enum { + OPT_OU = 1000 +}; + +int main(int argc, const char **argv) +{ + NET_API_STATUS status; + const char *host_name = NULL; + const char *domain_name = NULL; + const char *account_ou = NULL; + const char *account = NULL; + const char *password = NULL; + uint32_t join_flags = NETSETUP_JOIN_DOMAIN | + NETSETUP_ACCT_CREATE | + NETSETUP_DOMAIN_JOIN_IF_JOINED; + struct libnetapi_ctx *ctx = NULL; + + poptContext pc; + int opt; + + struct poptOption long_options[] = { + POPT_AUTOHELP + { "ou", 0, POPT_ARG_STRING, &account_ou, 'U', "Account ou", "ACCOUNT_OU" }, + { "domain", 0, POPT_ARG_STRING, &domain_name, 'U', "Domain name (required)", "DOMAIN" }, + { "userd", 0, POPT_ARG_STRING, &account, 'U', "Domain admin account", "USERNAME" }, + { "passwordd", 0, POPT_ARG_STRING, &password, 'U', "Domain admin password", "PASSWORD" }, + POPT_COMMON_LIBNETAPI_EXAMPLES + POPT_TABLEEND + }; + + + status = libnetapi_init(&ctx); + if (status != 0) { + return status; + } + + pc = poptGetContext("netdomjoin", argc, argv, long_options, 0); + + poptSetOtherOptionHelp(pc, "hostname"); + while((opt = poptGetNextOpt(pc)) != -1) { + } + + if (!poptPeekArg(pc)) { + poptPrintHelp(pc, stderr, 0); + goto out; + } + host_name = poptGetArg(pc); + + if (!domain_name) { + poptPrintHelp(pc, stderr, 0); + goto out; + } + + /* NetJoinDomain */ + + status = NetJoinDomain(host_name, + domain_name, + account_ou, + account, + password, + join_flags); + if (status != 0) { + const char *errstr = NULL; + errstr = libnetapi_get_error_string(ctx, status); + printf("Join failed with: %s\n", errstr); + } else { + printf("Successfully joined\n"); + } + + out: + libnetapi_free(ctx); + poptFreeContext(pc); + + return status; +} diff --git a/source/lib/netapi/examples/join/rename_machine.c b/source/lib/netapi/examples/join/rename_machine.c new file mode 100644 index 0000000..a21f919 --- /dev/null +++ b/source/lib/netapi/examples/join/rename_machine.c @@ -0,0 +1,86 @@ +/* + * Unix SMB/CIFS implementation. + * NetRenameMachineInDomain 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 <string.h> +#include <stdio.h> +#include <sys/types.h> +#include <inttypes.h> + +#include <netapi.h> + +#include "common.h" + +int main(int argc, const char **argv) +{ + NET_API_STATUS status; + const char *host_name = NULL; + const char *new_machine_name = NULL; + uint32_t rename_opt = 0; + struct libnetapi_ctx *ctx = 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("rename_machine", argc, argv, long_options, 0); + + poptSetOtherOptionHelp(pc, "hostname newmachinename"); + while((opt = poptGetNextOpt(pc)) != -1) { + } + + if (!poptPeekArg(pc)) { + poptPrintHelp(pc, stderr, 0); + goto out; + } + host_name = poptGetArg(pc); + + if (!poptPeekArg(pc)) { + poptPrintHelp(pc, stderr, 0); + goto out; + } + new_machine_name = poptGetArg(pc); + + /* NetRenameMachineInDomain */ + + status = NetRenameMachineInDomain(host_name, + new_machine_name, + ctx->username, + ctx->password, + rename_opt); + if (status != 0) { + printf("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/netdomjoin/netdomjoin.c b/source/lib/netapi/examples/netdomjoin/netdomjoin.c deleted file mode 100644 index 08ce71b..0000000 --- a/source/lib/netapi/examples/netdomjoin/netdomjoin.c +++ /dev/null @@ -1,104 +0,0 @@ -/* - * Unix SMB/CIFS implementation. - * Join Support (cmdline + netapi) - * Copyright (C) Guenther Deschner 2007-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" - -enum { - OPT_OU = 1000 -}; - -int main(int argc, const char **argv) -{ - NET_API_STATUS status; - const char *host_name = NULL; - const char *domain_name = NULL; - const char *account_ou = NULL; - const char *account = NULL; - const char *password = NULL; - uint32_t join_flags = NETSETUP_JOIN_DOMAIN | - NETSETUP_ACCT_CREATE | - NETSETUP_DOMAIN_JOIN_IF_JOINED; - struct libnetapi_ctx *ctx = NULL; - - poptContext pc; - int opt; - - struct poptOption long_options[] = { - POPT_AUTOHELP - { "ou", 0, POPT_ARG_STRING, &account_ou, 'U', "Account ou", "ACCOUNT_OU" }, - { "domain", 0, POPT_ARG_STRING, &domain_name, 'U', "Domain name (required)", "DOMAIN" }, - { "userd", 0, POPT_ARG_STRING, &account, 'U', "Domain admin account", "USERNAME" }, -- Samba Shared Repository