From 77a2e13cb1950cfd591f31b6a12eae66c342e632 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Fri, 21 Dec 2007 17:05:55 +0100 Subject: Move libnetapi examples into subdirs. Guenther (This used to be commit 0c3de6f3458419e57daaa71f1dad679897388f5a) --- .../lib/netapi/examples/netdomjoin/netdomjoin.c | 107 +++++++++++++++++++++ 1 file changed, 107 insertions(+) create mode 100644 source3/lib/netapi/examples/netdomjoin/netdomjoin.c (limited to 'source3/lib/netapi/examples/netdomjoin/netdomjoin.c') diff --git a/source3/lib/netapi/examples/netdomjoin/netdomjoin.c b/source3/lib/netapi/examples/netdomjoin/netdomjoin.c new file mode 100644 index 0000000000..a2bb700250 --- /dev/null +++ b/source3/lib/netapi/examples/netdomjoin/netdomjoin.c @@ -0,0 +1,107 @@ +/* + * Unix SMB/CIFS implementation. + * Join Support (cmdline + netapi) + * Copyright (C) Guenther Deschner 2007 + * + * 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 . + */ + +#include +#include +#include +#include +#include + +#include + +char *get_string_param(const char *param) +{ + char *p; + + p = strchr(param, '='); + if (!p) { + return NULL; + } + + return (p+1); +} + +int main(int argc, char **argv) +{ + NET_API_STATUS status; + const char *server_name = NULL; + const char *domain_name = NULL; + const char *account_ou = NULL; + const char *Account = NULL; + const char *password = NULL; + uint32_t join_flags = 3; + struct libnetapi_ctx *ctx = NULL; + int i; + + status = libnetapi_init(&ctx); + if (status != 0) { + return status; + } + + if (argc < 2) { + printf("usage: netdomjoin\n"); + printf("\t[hostname=HOSTNAME] [domain=DOMAIN] \n"); + return 0; + } + + if (argc > 2) { + server_name = argv[1]; + } + + for (i=0; i