38b1aa2b2851287aa736a14f36742dd82226a3a1
[sfrench/samba-autobuild/.git] / source3 / utils / net_help.c
1 /* 
2    Samba Unix/Linux SMB client library 
3    net help commands
4    Copyright (C) 2002 Jim McDonough (jmcd@us.ibm.com)
5
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 2 of the License, or
9    (at your option) any later version.
10    
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.
15    
16    You should have received a copy of the GNU General Public License
17    along with this program; if not, write to the Free Software
18    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.  
19 */
20
21 #include "includes.h"
22
23 int net_common_methods_usage(int argc, const char**argv)
24 {
25         d_printf("Valid methods: (auto-detected if not specified)\n");
26         d_printf("\tads\t\t\t\tActive Directory (LDAP/Kerberos)\n");
27         d_printf("\trpc\t\t\t\tDCE-RPC\n");
28         d_printf("\trap\t\t\t\tRAP (older systems)\n");
29         d_printf("\n");
30 }
31
32 int net_common_flags_usage(int argc, const char **argv)
33 {
34         d_printf("Valid targets: choose one (none defaults to localhost)\n");
35         d_printf("\t-S or --server=<server>\t\tserver name\n");
36         d_printf("\t-I or --ipaddress=<ipaddr>\taddress of target server\n");
37         d_printf("\t-w or --workgroup=<wg>\t\ttarget workgroup or domain\n");
38
39         d_printf("\n");
40         d_printf("Valid miscellaneous options are:\n"); /* misc options */
41         d_printf("\t-p or --port=<port>\t\tconnection port on target\n");
42         d_printf("\t-W or --myworkgroup=<wg>\tclient workgroup\n");
43         d_printf("\t-d or --debug=<level>\t\tdebug level (0-10)\n");
44         d_printf("\t-n or --myname=<name>\t\tclient name\n");
45         d_printf("\t-U or --user=<name>\t\tuser name\n");
46         d_printf("\t-s or --conf=<path>\t\tpathname of smb.conf file\n");
47         d_printf("\t-l or --long\t\t\tDisplay full information\n");
48         return -1;
49 }
50
51 static int help_usage(int argc, const char **argv)
52 {
53         d_printf(
54 "\n"\
55 "Usage: net help <function>\n"\
56 "\n"\
57 "Valid functions are:\n"\
58 "  RPC RAP ADS FILE SHARE SESSION SERVER DOMAIN PRINTQ USER GROUP VALIDATE\n"\
59 "  GROUPMEMBER ADMIN SERVICE PASSWORD TIME LOOKUP\n");
60         return -1;
61 }
62
63 int net_help_user(int argc, const char **argv)
64 {
65         d_printf("\nnet [method] user [misc. options] [targets]\n\tList users\n");
66         d_printf("\nnet [method] user DELETE <name> [misc. options] [targets]"\
67                  "\n\tDelete specified user\n");
68         d_printf("\nnet [method] user INFO <name> [misc. options] [targets]"\
69                  "\n\tList the domain groups of the specified user\n");
70         d_printf("\nnet [method] user ADD <name> [-F user flags] [misc. options]"\
71                  " [targets]\n\tAdd specified user\n");
72
73         net_common_methods_usage(argc, argv);
74         net_common_flags_usage(argc, argv);
75         d_printf(
76          "\t-C or --comment=<comment>\tdescriptive comment (for add only)\n");
77         return -1;
78 }
79
80 static int net_usage(int argc, const char **argv)
81 {
82         d_printf("  net time\t\tto view or set time information\n"\
83                  "  net lookup\t\tto lookup host name or ip address\n"\
84                  "  net user\t\tto manage users\n"\
85                  "  net join\t\tto join a domain\n"\
86                  "\n"\
87                  "  net ads [command]\tto run ADS commands\n"\
88                  "  net rap [command]\tto run RAP (pre-RPC) commands\n"\
89                  "  net rpc [command]\tto run RPC commands\n"\
90                  "\n"\
91                  "Type \"net help <option>\" to get more information on that option\n");
92         return -1;
93 }
94
95 /*
96   handle "net help *" subcommands
97 */
98 int net_help(int argc, const char **argv)
99 {
100         struct functable func[] = {
101                 {"ADS", net_ads_help},  
102                 {"RAP", net_rap_help},
103                 {"RPC", net_rpc_help},
104
105                 {"FILE", net_rap_file_usage},
106                 {"SHARE", net_rap_share_usage},
107                 {"SESSION", net_rap_session_usage},
108                 {"SERVER", net_rap_server_usage},
109                 {"DOMAIN", net_rap_domain_usage},
110                 {"PRINTQ", net_rap_printq_usage},
111                 {"USER", net_help_user},
112                 {"GROUP", net_rap_group_usage},
113                 {"VALIDATE", net_rap_validate_usage},
114                 {"GROUPMEMBER", net_rap_groupmember_usage},
115                 {"ADMIN", net_rap_admin_usage},
116                 {"SERVICE", net_rap_service_usage},
117                 {"PASSWORD", net_rap_password_usage},
118                 {"TIME", net_time_usage},
119                 {"LOOKUP", net_lookup_usage},
120
121                 {"HELP", help_usage},
122                 {NULL, NULL}};
123
124         return net_run_function(argc, argv, func, net_usage);
125 }