2 Samba Unix/Linux SMB client library
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.
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");
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");
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 --debug=<level>\t\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 --conf=<path>\t\tpathname of smb.conf file\n");
49 d_printf("\t-l or --long\t\t\tDisplay full information\n");
50 d_printf("\t-P or --machine-pass\t\tAuthenticate as machine account\n");
54 static int help_usage(int argc, const char **argv)
58 "Usage: net help <function>\n"\
60 "Valid functions are:\n"\
61 " RPC RAP ADS FILE SHARE SESSION SERVER DOMAIN PRINTQ USER GROUP VALIDATE\n"\
62 " GROUPMEMBER ADMIN SERVICE PASSWORD TIME LOOKUP GETLOCALSID SETLOCALSID\n");
66 int net_help_user(int argc, const char **argv)
68 d_printf("\nnet [<method>] user [misc. options] [targets]"\
69 "\n\tList users\n\n");
70 d_printf("net [<method>] user DELETE <name> [misc. options] [targets]"\
71 "\n\tDelete specified user\n");
72 d_printf("\nnet [<method>] user INFO <name> [misc. options] [targets]"\
73 "\n\tList the domain groups of the specified user\n");
74 d_printf("\nnet [<method>] user ADD <name> [password] [-c container] "\
75 "[-F user flags] [misc. options]"\
76 " [targets]\n\tAdd specified user\n");
78 net_common_methods_usage(argc, argv);
79 net_common_flags_usage(argc, argv);
80 d_printf("\t-C or --comment=<comment>\tdescriptive comment (for add only)\n");
81 d_printf("\t-c or --container=<container>\tLDAP container, defaults to cn=Users (for add in ADS only)\n");
85 int net_help_group(int argc, const char **argv)
87 d_printf("net [<method>] group [misc. options] [targets]"\
88 "\n\tList user groups\n\n");
89 d_printf("net [<method>] group DELETE <name> "\
90 "[misc. options] [targets]"\
91 "\n\tDelete specified group\n");
92 d_printf("\nnet [<method>] group ADD <name> [-C comment] [-c container]"\
93 " [misc. options] [targets]\n\tCreate specified group\n");
94 net_common_methods_usage(argc, argv);
95 net_common_flags_usage(argc, argv);
96 d_printf("\t-C or --comment=<comment>\tdescriptive comment (for add only)\n");
97 d_printf("\t-c or --container=<container>\tLDAP container, defaults to cn=Users (for add in ADS only)\n");
102 int net_help_join(int argc, const char **argv)
104 d_printf("\nnet [<method>] join [misc. options]\n"
105 "\tjoins this server to a domain\n");
106 d_printf("Valid methods: (auto-detected if not specified)\n");
107 d_printf("\tads\t\t\t\tActive Directory (LDAP/Kerberos)\n");
108 d_printf("\trpc\t\t\t\tDCE-RPC\n");
109 net_common_flags_usage(argc, argv);
113 int net_help_share(int argc, const char **argv)
116 "\nnet [<method>] share [misc. options] [targets] \n"
117 "\tenumerates all exported resources (network shares) "
118 "on target server\n\n"
119 "net [<method>] share ADD <name=serverpath> [misc. options] [targets]"
120 "\n\tAdds a share from a server (makes the export active)\n\n"
121 "net [<method>] share DELETE <sharename> [misc. options] [targets]\n"
122 "\n\tDeletes a share from a server (makes the export inactive)\n");
123 net_common_methods_usage(argc, argv);
124 net_common_flags_usage(argc, argv);
126 "\t-C or --comment=<comment>\tdescriptive comment (for add only)\n"
127 "\t-M or --maxusers=<num>\t\tmax users allowed for share\n");
131 int net_help_file(int argc, const char **argv)
133 d_printf("net [<method>] file [misc. options] [targets]\n"\
134 "\tlists all open files on file server\n\n");
135 d_printf("net [<method>] file USER <username> "\
136 "[misc. options] [targets]"\
137 "\n\tlists all files opened by username on file server\n\n");
138 d_printf("net [<method>] file CLOSE <id> [misc. options] [targets]\n"\
139 "\tcloses specified file on target server\n\n");
140 d_printf("net [rap] file INFO <id> [misc. options] [targets]\n"\
141 "\tdisplays information about the specified open file\n");
143 net_common_methods_usage(argc, argv);
144 net_common_flags_usage(argc, argv);
148 static int net_usage(int argc, const char **argv)
150 d_printf(" net time\t\tto view or set time information\n"\
151 " net lookup\t\tto lookup host name or ip address\n"\
152 " net user\t\tto manage users\n"\
153 " net group\t\tto manage groups\n"\
154 " net join\t\tto join a domain\n"\
155 " net cache\t\tto operate on cache tdb file\n"\
156 " net getlocalsid [NAME]\tto get the SID for local name\n"\
157 " net setlocalsid SID\tto set the local domain SID\n"\
159 " net ads <command>\tto run ADS commands\n"\
160 " net rap <command>\tto run RAP (pre-RPC) commands\n"\
161 " net rpc <command>\tto run RPC commands\n"\
163 "Type \"net help <option>\" to get more information on that option\n");
164 net_common_flags_usage(argc, argv);
169 handle "net help *" subcommands
171 int net_help(int argc, const char **argv)
173 struct functable func[] = {
174 {"ADS", net_ads_help},
175 {"RAP", net_rap_help},
176 {"RPC", net_rpc_help},
178 {"FILE", net_help_file},
179 {"SHARE", net_help_share},
180 {"SESSION", net_rap_session_usage},
181 {"SERVER", net_rap_server_usage},
182 {"DOMAIN", net_rap_domain_usage},
183 {"PRINTQ", net_rap_printq_usage},
184 {"USER", net_help_user},
185 {"GROUP", net_help_group},
186 {"JOIN", net_help_join},
187 {"VALIDATE", net_rap_validate_usage},
188 {"GROUPMEMBER", net_rap_groupmember_usage},
189 {"ADMIN", net_rap_admin_usage},
190 {"SERVICE", net_rap_service_usage},
191 {"PASSWORD", net_rap_password_usage},
192 {"TIME", net_time_usage},
193 {"LOOKUP", net_lookup_usage},
195 {"HELP", help_usage},
198 return net_run_function(argc, argv, func, net_usage);