r2565: syncing up for 3.0.8pre1
[Samba.git] / source / utils / net_help.c
blobd6ef5e8a6c300d8d59d0a80ea73222ae7486d7f2
1 /*
2 Samba Unix/Linux SMB client library
3 net help commands
4 Copyright (C) 2002 Jim McDonough (jmcd@us.ibm.com)
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.
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.
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.
21 #include "includes.h"
22 #include "../utils/net.h"
24 int net_common_methods_usage(int argc, const char**argv)
26 d_printf("Valid methods: (auto-detected if not specified)\n");
27 d_printf("\tads\t\t\t\tActive Directory (LDAP/Kerberos)\n");
28 d_printf("\trpc\t\t\t\tDCE-RPC\n");
29 d_printf("\trap\t\t\t\tRAP (older systems)\n");
30 d_printf("\n");
31 return 0;
34 int net_common_flags_usage(int argc, const char **argv)
36 d_printf("Valid targets: choose one (none defaults to localhost)\n");
37 d_printf("\t-S or --server=<server>\t\tserver name\n");
38 d_printf("\t-I or --ipaddress=<ipaddr>\taddress of target server\n");
39 d_printf("\t-w or --workgroup=<wg>\t\ttarget workgroup or domain\n");
41 d_printf("\n");
42 d_printf("Valid miscellaneous options are:\n"); /* misc options */
43 d_printf("\t-p or --port=<port>\t\tconnection port on target\n");
44 d_printf("\t-W or --myworkgroup=<wg>\tclient workgroup\n");
45 d_printf("\t-d or --debuglevel=<level>\tdebug level (0-10)\n");
46 d_printf("\t-n or --myname=<name>\t\tclient name\n");
47 d_printf("\t-U or --user=<name>\t\tuser name\n");
48 d_printf("\t-s or --configfile=<path>\tpathname of smb.conf file\n");
49 d_printf("\t-l or --long\t\t\tDisplay full information\n");
50 d_printf("\t-V or --version\t\t\tPrint samba version information\n");
51 d_printf("\t-P or --machine-pass\t\tAuthenticate as machine account\n");
52 return -1;
55 static int help_usage(int argc, const char **argv)
57 d_printf(
58 "\n"\
59 "Usage: net help <function>\n"\
60 "\n"\
61 "Valid functions are:\n"\
62 " RPC RAP ADS FILE SHARE SESSION SERVER DOMAIN PRINTQ USER GROUP VALIDATE\n"\
63 " GROUPMEMBER ADMIN SERVICE PASSWORD TIME LOOKUP GETLOCALSID SETLOCALSID\n"\
64 " CHANGESCRETPW\n");
65 return -1;
68 int net_help_user(int argc, const char **argv)
70 d_printf("\nnet [<method>] user [misc. options] [targets]"\
71 "\n\tList users\n\n");
72 d_printf("net [<method>] user DELETE <name> [misc. options] [targets]"\
73 "\n\tDelete specified user\n");
74 d_printf("\nnet [<method>] user INFO <name> [misc. options] [targets]"\
75 "\n\tList the domain groups of the specified user\n");
76 d_printf("\nnet [<method>] user ADD <name> [password] [-c container] "\
77 "[-F user flags] [misc. options]"\
78 " [targets]\n\tAdd specified user\n");
80 net_common_methods_usage(argc, argv);
81 net_common_flags_usage(argc, argv);
82 d_printf("\t-C or --comment=<comment>\tdescriptive comment (for add only)\n");
83 d_printf("\t-c or --container=<container>\tLDAP container, defaults to cn=Users (for add in ADS only)\n");
84 return -1;
87 int net_help_group(int argc, const char **argv)
89 d_printf("net [<method>] group [misc. options] [targets]"\
90 "\n\tList user groups\n\n");
91 d_printf("net rpc group LIST [global|local|builtin]* [misc. options]"\
92 "\n\tList specific user groups\n\n");
93 d_printf("net [<method>] group DELETE <name> "\
94 "[misc. options] [targets]"\
95 "\n\tDelete specified group\n");
96 d_printf("\nnet [<method>] group ADD <name> [-C comment] [-c container]"\
97 " [misc. options] [targets]\n\tCreate specified group\n");
98 d_printf("\nnet rpc group MEMBERS <name>\n\tList Group Members\n\n");
99 net_common_methods_usage(argc, argv);
100 net_common_flags_usage(argc, argv);
101 d_printf("\t-C or --comment=<comment>\tdescriptive comment (for add only)\n");
102 d_printf("\t-c or --container=<container>\tLDAP container, defaults to cn=Users (for add in ADS only)\n");
103 return -1;
106 int net_help_join(int argc, const char **argv)
108 d_printf("\nnet [<method>] join [misc. options]\n"
109 "\tjoins this server to a domain\n");
110 d_printf("Valid methods: (auto-detected if not specified)\n");
111 d_printf("\tads\t\t\t\tActive Directory (LDAP/Kerberos)\n");
112 d_printf("\trpc\t\t\t\tDCE-RPC\n");
113 net_common_flags_usage(argc, argv);
114 return -1;
117 int net_help_share(int argc, const char **argv)
119 d_printf(
120 "\nnet [<method>] share [misc. options] [targets] \n"
121 "\tenumerates all exported resources (network shares) "
122 "on target server\n\n"
123 "net [<method>] share ADD <name=serverpath> [misc. options] [targets]"
124 "\n\tAdds a share from a server (makes the export active)\n\n"
125 "net [<method>] share DELETE <sharename> [misc. options] [targets]"
126 "\n\tDeletes a share from a server (makes the export inactive)\n\n"
127 "net [<method>] share MIGRATE FILES <sharename> [misc. options] [targets]"
128 "\n\tMigrates files from remote to local server\n\n"
129 "net [<method>] share MIGRATE SHARES <sharename> [misc. options] [targets]"
130 "\n\tMigrates shares from remote to local server\n\n"
131 /* "net [<method>] share MIGRATE SECURITY <sharename> [misc. options] [targets]"
132 "\n\tMigrates share-ACLs from remote to local server\n\n" */
133 "net [<method>] share MIGRATE ALL <sharename> [misc. options] [targets]"
134 "\n\tMigrates shares (including directories, files) from remote\n"
135 "\tto local server\n\n"
137 net_common_methods_usage(argc, argv);
138 net_common_flags_usage(argc, argv);
139 d_printf(
140 "\t-C or --comment=<comment>\tdescriptive comment (for add only)\n"
141 "\t-M or --maxusers=<num>\t\tmax users allowed for share\n"
142 "\t --acls\t\t\tcopies ACLs as well\n"
143 "\t --attrs\t\t\tcopies DOS Attributes as well\n"
144 "\t --timestampes\t\tpreserve timestampes while copying files\n"
145 "\t --destination\t\tmigration target server (default: localhost)\n"
146 "\t-e or --exclude\t\t\tlist of shares to be excluded from mirroring\n"
147 "\t-v or --verbose\t\t\tgive verbose output\n");
148 return -1;
151 int net_help_file(int argc, const char **argv)
153 d_printf("net [<method>] file [misc. options] [targets]\n"\
154 "\tlists all open files on file server\n\n");
155 d_printf("net [<method>] file USER <username> "\
156 "[misc. options] [targets]"\
157 "\n\tlists all files opened by username on file server\n\n");
158 d_printf("net [<method>] file CLOSE <id> [misc. options] [targets]\n"\
159 "\tcloses specified file on target server\n\n");
160 d_printf("net [rap] file INFO <id> [misc. options] [targets]\n"\
161 "\tdisplays information about the specified open file\n");
163 net_common_methods_usage(argc, argv);
164 net_common_flags_usage(argc, argv);
165 return -1;
168 int net_help_printer(int argc, const char **argv)
170 d_printf("net rpc printer LIST [printer] [misc. options] [targets]\n"\
171 "\tlists all printers on print-server\n\n");
172 d_printf("net rpc printer DRIVER [printer] [misc. options] [targets]\n"\
173 "\tlists all printer-drivers on print-server\n\n");
174 d_printf("net rpc printer MIGRATE PRINTERS [printer] [misc. options] [targets]"\
175 "\n\tmigrates printers from remote to local server\n\n");
176 d_printf("net rpc printer MIGRATE SETTINGS [printer] [misc. options] [targets]"\
177 "\n\tmigrates printer-settings from remote to local server\n\n");
178 d_printf("net rpc printer MIGRATE DRIVERS [printer] [misc. options] [targets]"\
179 "\n\tmigrates printer-drivers from remote to local server\n\n");
180 d_printf("net rpc printer MIGRATE FORMS [printer] [misc. options] [targets]"\
181 "\n\tmigrates printer-forms from remote to local server\n\n");
182 d_printf("net rpc printer MIGRATE SECURITY [printer] [misc. options] [targets]"\
183 "\n\tmigrates printer-ACLs from remote to local server\n\n");
184 d_printf("net rpc printer MIGRATE ALL [printer] [misc. options] [targets]"\
185 "\n\tmigrates drivers, forms, queues, settings and acls from\n"\
186 "\tremote to local print-server\n\n");
187 net_common_methods_usage(argc, argv);
188 net_common_flags_usage(argc, argv);
189 d_printf(
190 "\t-v or --verbose\t\t\tgive verbose output\n"
191 "\t --destination\t\tmigration target server (default: localhost)\n");
193 return -1;
197 int net_help_status(int argc, const char **argv)
199 d_printf(" net status sessions [parseable] "
200 "Show list of open sessions\n");
201 d_printf(" net status shares [parseable] "
202 "Show list of open shares\n");
203 return -1;
206 static int net_usage(int argc, const char **argv)
208 d_printf(" net time\t\tto view or set time information\n"\
209 " net lookup\t\tto lookup host name or ip address\n"\
210 " net user\t\tto manage users\n"\
211 " net group\t\tto manage groups\n"\
212 " net groupmap\t\tto manage group mappings\n"\
213 " net join\t\tto join a domain\n"\
214 " net cache\t\tto operate on cache tdb file\n"\
215 " net getlocalsid [NAME]\tto get the SID for local name\n"\
216 " net setlocalsid SID\tto set the local domain SID\n"\
217 " net changesecretpw\tto change the machine password in the local secrets database only\n"\
218 " \tthis requires the -f flag as a safety barrier\n"\
219 " net status\t\tShow server status\n"\
220 "\n"\
221 " net ads <command>\tto run ADS commands\n"\
222 " net rap <command>\tto run RAP (pre-RPC) commands\n"\
223 " net rpc <command>\tto run RPC commands\n"\
224 "\n"\
225 "Type \"net help <option>\" to get more information on that option\n");
226 net_common_flags_usage(argc, argv);
227 return -1;
231 handle "net help *" subcommands
233 int net_help(int argc, const char **argv)
235 struct functable func[] = {
236 {"ADS", net_ads_help},
237 {"RAP", net_rap_help},
238 {"RPC", net_rpc_help},
240 {"FILE", net_help_file},
241 {"SHARE", net_help_share},
242 {"SESSION", net_rap_session_usage},
243 {"SERVER", net_rap_server_usage},
244 {"DOMAIN", net_rap_domain_usage},
245 {"PRINTQ", net_rap_printq_usage},
246 {"USER", net_help_user},
247 {"GROUP", net_help_group},
248 {"GROUPMAP", net_help_groupmap},
249 {"JOIN", net_help_join},
250 {"VALIDATE", net_rap_validate_usage},
251 {"GROUPMEMBER", net_rap_groupmember_usage},
252 {"ADMIN", net_rap_admin_usage},
253 {"SERVICE", net_rap_service_usage},
254 {"PASSWORD", net_rap_password_usage},
255 {"TIME", net_time_usage},
256 {"LOOKUP", net_lookup_usage},
257 #ifdef WITH_FAKE_KASERVER
258 {"AFSKEY", net_afskey_usage},
259 #endif
261 {"HELP", help_usage},
262 {NULL, NULL}};
264 return net_run_function(argc, argv, func, net_usage);