netapi: add NetUserSetGroups to public header.
[Samba/gbeck.git] / source3 / utils / net_join.c
blob98188aae5fdb91a7548ae68ef9ce5470e4b3d221
1 /*
2 Samba Unix/Linux SMB client library
3 net join commands
4 Copyright (C) 2002 Jim McDonough (jmcd@us.ibm.com)
5 Copyright (C) 2008 Kai Blin (kai@samba.org)
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 3 of the License, or
10 (at your option) any later version.
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this program. If not, see <http://www.gnu.org/licenses/>.
21 #include "includes.h"
22 #include "utils/net.h"
24 int net_join_usage(struct net_context *c, int argc, const char **argv)
26 d_printf("\nnet [<method>] join [misc. options]\n"
27 "\tjoins this server to a domain\n");
28 d_printf("Valid methods: (auto-detected if not specified)\n");
29 d_printf("\tads\t\t\t\tActive Directory (LDAP/Kerberos)\n");
30 d_printf("\trpc\t\t\t\tDCE-RPC\n");
31 net_common_flags_usage(c, argc, argv);
32 return -1;
35 int net_join(struct net_context *c, int argc, const char **argv)
37 if (argc < 1)
38 return net_join_usage(c, argc, argv);
40 if (StrCaseCmp(argv[0], "HELP") == 0) {
41 net_join_usage(c, argc, argv);
42 return 0;
45 if (net_ads_check_our_domain(c) == 0) {
46 if (net_ads_join(c, argc, argv) == 0)
47 return 0;
48 else
49 d_fprintf(stderr, "ADS join did not work, falling back to RPC...\n");
51 return net_rpc_join(c, argc, argv);