net: Split out "net group"
[bbaumbach/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 3 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, see <http://www.gnu.org/licenses/>.
18 */
19
20 #include "includes.h"
21 #include "utils/net.h"
22
23 static int help_usage(struct net_context *c, int argc, const char **argv)
24 {
25         d_printf(
26 "\n"\
27 "Usage: net help <function>\n"\
28 "\n"\
29 "Valid functions are:\n"\
30 "  RPC RAP ADS FILE SHARE SESSION SERVER DOMAIN PRINTQ USER GROUP VALIDATE\n"\
31 "  GROUPMEMBER ADMIN SERVICE PASSWORD TIME LOOKUP GETLOCALSID SETLOCALSID\n"\
32 "  SETDOMAINSID CHANGESCRETPW LOOKUP SAM\n");
33         return -1;
34 }
35
36 int net_help_share(struct net_context *c, int argc, const char **argv)
37 {
38         d_printf(
39          "\nnet [<method>] share [misc. options] [targets] \n"
40          "\tenumerates all exported resources (network shares) "
41          "on target server\n\n"
42          "net [<method>] share ADD <name=serverpath> [misc. options] [targets]"
43         "\n\tadds a share from a server (makes the export active)\n\n"
44         "net [<method>] share DELETE <sharename> [misc. options] [targets]"
45         "\n\tdeletes a share from a server (makes the export inactive)\n\n"
46         "net [<method>] share ALLOWEDUSERS [<filename>] "
47         "[misc. options] [targets]"
48         "\n\tshows a list of all shares together with all users allowed to"
49         "\n\taccess them. This needs the output of 'net usersidlist' on"
50         "\n\tstdin or in <filename>.\n\n"
51          "net [<method>] share MIGRATE FILES <sharename> [misc. options] [targets]"
52          "\n\tMigrates files from remote to local server\n\n"
53          "net [<method>] share MIGRATE SHARES <sharename> [misc. options] [targets]"
54          "\n\tMigrates shares from remote to local server\n\n"
55          "net [<method>] share MIGRATE SECURITY <sharename> [misc. options] [targets]"
56          "\n\tMigrates share-ACLs from remote to local server\n\n"
57          "net [<method>] share MIGRATE ALL <sharename> [misc. options] [targets]"
58          "\n\tMigrates shares (including directories, files) from remote\n"
59          "\tto local server\n\n"
60         );
61         net_common_methods_usage(c, argc, argv);
62         net_common_flags_usage(c, argc, argv);
63         d_printf(
64          "\t-C or --comment=<comment>\tdescriptive comment (for add only)\n"
65          "\t-M or --maxusers=<num>\t\tmax users allowed for share\n"
66          "\t      --acls\t\t\tcopies ACLs as well\n"
67          "\t      --attrs\t\t\tcopies DOS Attributes as well\n"
68          "\t      --timestamps\t\tpreserve timestamps while copying files\n"
69          "\t      --destination\t\tmigration target server (default: localhost)\n"
70          "\t-e or --exclude\t\t\tlist of shares to be excluded from mirroring\n"
71          "\t-v or --verbose\t\t\tgive verbose output\n");
72         return -1;
73 }
74
75 int net_help_file(struct net_context *c, int argc, const char **argv)
76 {
77         d_printf("net [<method>] file [misc. options] [targets]\n"\
78                  "\tlists all open files on file server\n\n");
79         d_printf("net [<method>] file USER <username> "\
80                  "[misc. options] [targets]"\
81                  "\n\tlists all files opened by username on file server\n\n");
82         d_printf("net [<method>] file CLOSE <id> [misc. options] [targets]\n"\
83                  "\tcloses specified file on target server\n\n");
84         d_printf("net [rap] file INFO <id> [misc. options] [targets]\n"\
85                  "\tdisplays information about the specified open file\n");
86
87         net_common_methods_usage(c, argc, argv);
88         net_common_flags_usage(c, argc, argv);
89         return -1;
90 }
91
92 int net_help_printer(struct net_context *c, int argc, const char **argv)
93 {
94         d_printf("net rpc printer LIST [printer] [misc. options] [targets]\n"\
95                  "\tlists all printers on print-server\n\n");
96         d_printf("net rpc printer DRIVER [printer] [misc. options] [targets]\n"\
97                  "\tlists all printer-drivers on print-server\n\n");
98         d_printf("net rpc printer PUBLISH action [printer] [misc. options] [targets]\n"\
99                  "\tpublishes printer settings in Active Directory\n"
100                  "\taction can be one of PUBLISH, UPDATE, UNPUBLISH or LIST\n\n");
101         d_printf("net rpc printer MIGRATE PRINTERS [printer] [misc. options] [targets]"\
102                  "\n\tmigrates printers from remote to local server\n\n");
103         d_printf("net rpc printer MIGRATE SETTINGS [printer] [misc. options] [targets]"\
104                  "\n\tmigrates printer-settings from remote to local server\n\n");
105         d_printf("net rpc printer MIGRATE DRIVERS [printer] [misc. options] [targets]"\
106                  "\n\tmigrates printer-drivers from remote to local server\n\n");
107         d_printf("net rpc printer MIGRATE FORMS [printer] [misc. options] [targets]"\
108                  "\n\tmigrates printer-forms from remote to local server\n\n");
109         d_printf("net rpc printer MIGRATE SECURITY [printer] [misc. options] [targets]"\
110                  "\n\tmigrates printer-ACLs from remote to local server\n\n");
111         d_printf("net rpc printer MIGRATE ALL [printer] [misc. options] [targets]"\
112                  "\n\tmigrates drivers, forms, queues, settings and acls from\n"\
113                  "\tremote to local print-server\n\n");
114         net_common_methods_usage(c, argc, argv);
115         net_common_flags_usage(c, argc, argv);
116         d_printf(
117          "\t-v or --verbose\t\t\tgive verbose output\n"
118          "\t      --destination\t\tmigration target server (default: localhost)\n");
119
120         return -1;
121 }
122
123
124 int net_help_status(struct net_context *c, int argc, const char **argv)
125 {
126         d_printf("  net status sessions [parseable] "
127                  "Show list of open sessions\n");
128         d_printf("  net status shares [parseable]   "
129                  "Show list of open shares\n");
130         return -1;
131 }
132
133 static int net_usage(struct net_context *c, int argc, const char **argv)
134 {
135         d_printf("  net time\t\tto view or set time information\n"\
136                  "  net lookup\t\tto lookup host name or ip address\n"\
137                  "  net user\t\tto manage users\n"\
138                  "  net group\t\tto manage groups\n"\
139                  "  net sam\t\tto edit the local user database directly\n"\
140                  "  net lookup\t\tto look up various things\n"\
141                  "  net groupmap\t\tto manage group mappings\n"\
142                  "  net join\t\tto join a domain\n"\
143                  "  net cache\t\tto operate on cache tdb file\n"\
144                  "  net getlocalsid [NAME]\tto get the SID for local name\n"\
145                  "  net setlocalsid SID\tto set the local domain SID\n"\
146                  "  net setdomainsid SID\tto set the domain SID on member servers\n"\
147                  "  net changesecretpw\tto change the machine password in the local secrets database only\n"\
148                  "                    \tthis requires the -f flag as a safety barrier\n"\
149                  "  net status\t\tShow server status\n"\
150                  "  net usersidlist\tto get a list of all users with their SIDs\n"
151                  "  net usershare\t\tto add, delete and list locally user-modifiable shares\n"
152                  "  net conf\t\tto view and edit samba's registry based configuration\n"
153                  "\n"\
154                  "  net ads <command>\tto run ADS commands\n"\
155                  "  net rap <command>\tto run RAP (pre-RPC) commands\n"\
156                  "  net rpc <command>\tto run RPC commands\n"\
157                  "\n"\
158                  "Type \"net help <option>\" to get more information on that option\n");
159         net_common_flags_usage(c, argc, argv);
160         return -1;
161 }
162
163 /*
164   handle "net help *" subcommands
165 */
166 int net_help(struct net_context *c, int argc, const char **argv)
167 {
168         struct functable func[] = {
169                 {"ADS", net_ads_help},
170                 {"RAP", net_rap_help},
171                 {"RPC", net_rpc_help},
172
173                 {"FILE", net_help_file},
174                 {"SHARE", net_help_share},
175                 {"SESSION", net_rap_session_usage},
176                 {"SERVER", net_rap_server_usage},
177                 {"DOMAIN", net_rap_domain_usage},
178                 {"PRINTQ", net_rap_printq_usage},
179                 {"USER", net_user_usage},
180                 {"GROUP", net_group_usage},
181                 {"GROUPMAP", net_help_groupmap},
182                 {"JOIN", net_join_usage},
183                 {"DOM", net_help_dom},
184                 {"VALIDATE", net_rap_validate_usage},
185                 {"GROUPMEMBER", net_rap_groupmember_usage},
186                 {"ADMIN", net_rap_admin_usage},
187                 {"SERVICE", net_rap_service_usage},
188                 {"PASSWORD", net_rap_password_usage},
189                 {"TIME", net_time_usage},
190                 {"LOOKUP", net_lookup_usage},
191                 {"USERSHARE", net_usershare_usage},
192                 {"USERSIDLIST", net_usersidlist_usage},
193 #ifdef WITH_FAKE_KASERVER
194                 {"AFS", net_help_afs},
195 #endif
196
197                 {"HELP", help_usage},
198                 {NULL, NULL}};
199
200         return net_run_function(c, argc, argv, func, net_usage);
201 }