2002-04-05 05:36:28 +04:00
/*
Samba Unix / Linux SMB client library
net help commands
Copyright ( C ) 2002 Jim McDonough ( jmcd @ us . ibm . com )
This program is free software ; you can redistribute it and / or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation ; either version 2 of the License , or
( at your option ) any later version .
This program is distributed in the hope that it will be useful ,
but WITHOUT ANY WARRANTY ; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE . See the
GNU General Public License for more details .
You should have received a copy of the GNU General Public License
along with this program ; if not , write to the Free Software
Foundation , Inc . , 675 Mass Ave , Cambridge , MA 0213 9 , USA .
*/
# include "includes.h"
2004-10-07 08:01:18 +04:00
# include "utils/net.h"
2002-04-05 05:36:28 +04:00
int net_common_methods_usage ( int argc , const char * * argv )
{
d_printf ( " Valid methods: (auto-detected if not specified) \n " ) ;
d_printf ( " \t ads \t \t \t \t Active Directory (LDAP/Kerberos) \n " ) ;
d_printf ( " \t rpc \t \t \t \t DCE-RPC \n " ) ;
d_printf ( " \t rap \t \t \t \t RAP (older systems) \n " ) ;
d_printf ( " \n " ) ;
2002-04-10 04:36:06 +04:00
return 0 ;
2002-04-05 05:36:28 +04:00
}
int net_common_flags_usage ( int argc , const char * * argv )
{
d_printf ( " Valid targets: choose one (none defaults to localhost) \n " ) ;
d_printf ( " \t -S or --server=<server> \t \t server name \n " ) ;
d_printf ( " \t -I or --ipaddress=<ipaddr> \t address of target server \n " ) ;
d_printf ( " \t -w or --workgroup=<wg> \t \t target workgroup or domain \n " ) ;
d_printf ( " \n " ) ;
d_printf ( " Valid miscellaneous options are: \n " ) ; /* misc options */
d_printf ( " \t -p or --port=<port> \t \t connection port on target \n " ) ;
d_printf ( " \t -W or --myworkgroup=<wg> \t client workgroup \n " ) ;
2003-09-10 10:15:07 +04:00
d_printf ( " \t -d or --debuglevel=<level> \t debug level (0-10) \n " ) ;
2002-04-05 05:36:28 +04:00
d_printf ( " \t -n or --myname=<name> \t \t client name \n " ) ;
d_printf ( " \t -U or --user=<name> \t \t user name \n " ) ;
2003-09-10 10:15:07 +04:00
d_printf ( " \t -s or --configfile=<path> \t pathname of smb.conf file \n " ) ;
2002-04-05 05:36:28 +04:00
d_printf ( " \t -l or --long \t \t \t Display full information \n " ) ;
2003-08-29 00:24:25 +04:00
d_printf ( " \t -V or --version \t \t \t Print samba version information \n " ) ;
2003-03-18 01:33:34 +03:00
d_printf ( " \t -P or --machine-pass \t \t Authenticate as machine account \n " ) ;
2002-04-05 05:36:28 +04:00
return - 1 ;
}
static int help_usage ( int argc , const char * * argv )
{
d_printf (
" \n " \
" Usage: net help <function> \n " \
" \n " \
" Valid functions are: \n " \
" RPC RAP ADS FILE SHARE SESSION SERVER DOMAIN PRINTQ USER GROUP VALIDATE \n " \
2003-08-29 00:24:25 +04:00
" GROUPMEMBER ADMIN SERVICE PASSWORD TIME LOOKUP GETLOCALSID SETLOCALSID \n " \
2005-12-02 23:46:15 +03:00
" CHANGESCRETPW IDMAP \n " ) ;
2002-04-05 05:36:28 +04:00
return - 1 ;
}
int net_help_user ( int argc , const char * * argv )
{
2002-11-09 21:01:27 +03:00
d_printf ( " \n net [<method>] user [misc. options] [targets] " \
" \n \t List users \n \n " ) ;
d_printf ( " net [<method>] user DELETE <name> [misc. options] [targets] " \
2002-04-05 05:36:28 +04:00
" \n \t Delete specified user \n " ) ;
2002-11-09 21:01:27 +03:00
d_printf ( " \n net [<method>] user INFO <name> [misc. options] [targets] " \
2002-04-05 05:36:28 +04:00
" \n \t List the domain groups of the specified user \n " ) ;
2005-05-16 22:22:22 +04:00
d_printf ( " \n net [<method>] user ADD <name> [-c container] " \
2002-11-09 21:01:27 +03:00
" [-F user flags] [misc. options] " \
2002-04-05 05:36:28 +04:00
" [targets] \n \t Add specified user \n " ) ;
2005-01-20 19:51:24 +03:00
d_printf ( " \n net [<method>] user RENAME <oldusername> <newusername> " \
" [targets] \n \t Rename specified user \n \n " ) ;
2002-04-05 05:36:28 +04:00
net_common_methods_usage ( argc , argv ) ;
net_common_flags_usage ( argc , argv ) ;
2003-01-15 19:10:57 +03:00
d_printf ( " \t -C or --comment=<comment> \t descriptive comment (for add only) \n " ) ;
d_printf ( " \t -c or --container=<container> \t LDAP container, defaults to cn=Users (for add in ADS only) \n " ) ;
2002-04-05 05:36:28 +04:00
return - 1 ;
}
2002-07-15 14:35:28 +04:00
int net_help_group ( int argc , const char * * argv )
{
2002-11-09 21:01:27 +03:00
d_printf ( " net [<method>] group [misc. options] [targets] " \
2002-07-15 14:35:28 +04:00
" \n \t List user groups \n \n " ) ;
2003-11-28 18:10:00 +03:00
d_printf ( " net rpc group LIST [global|local|builtin]* [misc. options] " \
" \n \t List specific user groups \n \n " ) ;
2002-11-09 21:01:27 +03:00
d_printf ( " net [<method>] group DELETE <name> " \
" [misc. options] [targets] " \
2002-07-15 14:35:28 +04:00
" \n \t Delete specified group \n " ) ;
2003-01-15 19:10:57 +03:00
d_printf ( " \n net [<method>] group ADD <name> [-C comment] [-c container] " \
2002-07-15 14:35:28 +04:00
" [misc. options] [targets] \n \t Create specified group \n " ) ;
2003-11-26 13:07:07 +03:00
d_printf ( " \n net rpc group MEMBERS <name> \n \t List Group Members \n \n " ) ;
2005-03-03 21:55:36 +03:00
d_printf ( " \n net rpc group ADDMEM <group> <member> \n \t Add Group Members \n \n " ) ;
d_printf ( " \n net rpc group DELMEM <group> <member> \n \t Delete Group Members \n \n " ) ;
2002-07-15 14:35:28 +04:00
net_common_methods_usage ( argc , argv ) ;
net_common_flags_usage ( argc , argv ) ;
2003-01-15 19:10:57 +03:00
d_printf ( " \t -C or --comment=<comment> \t descriptive comment (for add only) \n " ) ;
d_printf ( " \t -c or --container=<container> \t LDAP container, defaults to cn=Users (for add in ADS only) \n " ) ;
2004-12-21 13:26:59 +03:00
d_printf ( " \t -L or --localgroup \t \t When adding groups, create a local group (alias) \n " ) ;
2002-07-15 14:35:28 +04:00
return - 1 ;
}
2002-11-09 21:01:27 +03:00
int net_help_join ( int argc , const char * * argv )
{
d_printf ( " \n net [<method>] join [misc. options] \n "
" \t joins this server to a domain \n " ) ;
d_printf ( " Valid methods: (auto-detected if not specified) \n " ) ;
d_printf ( " \t ads \t \t \t \t Active Directory (LDAP/Kerberos) \n " ) ;
d_printf ( " \t rpc \t \t \t \t DCE-RPC \n " ) ;
net_common_flags_usage ( argc , argv ) ;
return - 1 ;
}
2002-07-15 14:35:28 +04:00
int net_help_share ( int argc , const char * * argv )
{
d_printf (
2002-11-09 21:01:27 +03:00
" \n net [<method>] share [misc. options] [targets] \n "
2002-07-15 14:35:28 +04:00
" \t enumerates all exported resources (network shares) "
2002-11-09 21:01:27 +03:00
" on target server \n \n "
" net [<method>] share ADD <name=serverpath> [misc. options] [targets] "
2004-10-12 15:58:01 +04:00
" \n \t adds a share from a server (makes the export active) \n \n "
" net [<method>] share DELETE <sharename> [misc. options] [targets] "
" \n \t deletes a share from a server (makes the export inactive) \n \n "
" net [<method>] share ALLOWEDUSERS [<filename>] "
" [misc. options] [targets] "
" \n \t shows a list of all shares together with all users allowed to "
" \n \t access them. This needs the output of 'net usersidlist' on "
2005-01-25 04:19:02 +03:00
" \n \t stdin or in <filename>. \n \n "
2004-08-10 18:27:17 +04:00
" net [<method>] share MIGRATE FILES <sharename> [misc. options] [targets] "
" \n \t Migrates files from remote to local server \n \n "
" net [<method>] share MIGRATE SHARES <sharename> [misc. options] [targets] "
" \n \t Migrates shares from remote to local server \n \n "
2005-06-16 16:17:07 +04:00
" net [<method>] share MIGRATE SECURITY <sharename> [misc. options] [targets] "
" \n \t Migrates share-ACLs from remote to local server \n \n "
2004-08-10 18:27:17 +04:00
" net [<method>] share MIGRATE ALL <sharename> [misc. options] [targets] "
" \n \t Migrates shares (including directories, files) from remote \n "
" \t to local server \n \n "
) ;
2002-07-15 14:35:28 +04:00
net_common_methods_usage ( argc , argv ) ;
net_common_flags_usage ( argc , argv ) ;
d_printf (
" \t -C or --comment=<comment> \t descriptive comment (for add only) \n "
2004-08-10 18:27:17 +04:00
" \t -M or --maxusers=<num> \t \t max users allowed for share \n "
2004-08-21 00:13:05 +04:00
" \t --acls \t \t \t copies ACLs as well \n "
" \t --attrs \t \t \t copies DOS Attributes as well \n "
2005-03-12 21:03:54 +03:00
" \t --timestamps \t \t preserve timestamps while copying files \n "
2004-09-21 17:46:12 +04:00
" \t --destination \t \t migration target server (default: localhost) \n "
2004-08-21 00:13:05 +04:00
" \t -e or --exclude \t \t \t list of shares to be excluded from mirroring \n "
" \t -v or --verbose \t \t \t give verbose output \n " ) ;
2002-07-15 14:35:28 +04:00
return - 1 ;
}
int net_help_file ( int argc , const char * * argv )
{
2002-11-09 21:01:27 +03:00
d_printf ( " net [<method>] file [misc. options] [targets] \n " \
2002-07-15 14:35:28 +04:00
" \t lists all open files on file server \n \n " ) ;
2002-11-09 21:01:27 +03:00
d_printf ( " net [<method>] file USER <username> " \
" [misc. options] [targets] " \
2002-07-15 14:35:28 +04:00
" \n \t lists all files opened by username on file server \n \n " ) ;
2002-11-09 21:01:27 +03:00
d_printf ( " net [<method>] file CLOSE <id> [misc. options] [targets] \n " \
2002-07-15 14:35:28 +04:00
" \t closes specified file on target server \n \n " ) ;
d_printf ( " net [rap] file INFO <id> [misc. options] [targets] \n " \
" \t displays information about the specified open file \n " ) ;
net_common_methods_usage ( argc , argv ) ;
net_common_flags_usage ( argc , argv ) ;
return - 1 ;
}
2004-08-10 18:27:17 +04:00
int net_help_printer ( int argc , const char * * argv )
{
2004-08-21 00:13:05 +04:00
d_printf ( " net rpc printer LIST [printer] [misc. options] [targets] \n " \
2004-08-10 18:27:17 +04:00
" \t lists all printers on print-server \n \n " ) ;
2004-08-21 00:13:05 +04:00
d_printf ( " net rpc printer DRIVER [printer] [misc. options] [targets] \n " \
2004-08-10 18:27:17 +04:00
" \t lists all printer-drivers on print-server \n \n " ) ;
2004-10-13 05:40:35 +04:00
d_printf ( " net rpc printer PUBLISH action [printer] [misc. options] [targets] \n " \
" \t publishes printer settings in Active Directory \n "
" \t action can be one of PUBLISH, UPDATE, UNPUBLISH or LIST \n \n " ) ;
2004-08-21 00:13:05 +04:00
d_printf ( " net rpc printer MIGRATE PRINTERS [printer] [misc. options] [targets] " \
2004-08-10 18:27:17 +04:00
" \n \t migrates printers from remote to local server \n \n " ) ;
2004-08-21 00:13:05 +04:00
d_printf ( " net rpc printer MIGRATE SETTINGS [printer] [misc. options] [targets] " \
2004-08-10 18:27:17 +04:00
" \n \t migrates printer-settings from remote to local server \n \n " ) ;
2004-08-21 00:13:05 +04:00
d_printf ( " net rpc printer MIGRATE DRIVERS [printer] [misc. options] [targets] " \
2004-08-10 18:27:17 +04:00
" \n \t migrates printer-drivers from remote to local server \n \n " ) ;
2004-08-21 00:13:05 +04:00
d_printf ( " net rpc printer MIGRATE FORMS [printer] [misc. options] [targets] " \
2004-08-10 18:27:17 +04:00
" \n \t migrates printer-forms from remote to local server \n \n " ) ;
2004-08-21 00:13:05 +04:00
d_printf ( " net rpc printer MIGRATE SECURITY [printer] [misc. options] [targets] " \
2004-08-10 18:27:17 +04:00
" \n \t migrates printer-ACLs from remote to local server \n \n " ) ;
2004-08-21 00:13:05 +04:00
d_printf ( " net rpc printer MIGRATE ALL [printer] [misc. options] [targets] " \
" \n \t migrates drivers, forms, queues, settings and acls from \n " \
2004-08-10 18:27:17 +04:00
" \t remote to local print-server \n \n " ) ;
net_common_methods_usage ( argc , argv ) ;
net_common_flags_usage ( argc , argv ) ;
2004-08-21 00:13:05 +04:00
d_printf (
2004-09-21 17:46:12 +04:00
" \t -v or --verbose \t \t \t give verbose output \n "
" \t --destination \t \t migration target server (default: localhost) \n " ) ;
2004-08-21 00:13:05 +04:00
2004-08-10 18:27:17 +04:00
return - 1 ;
}
2003-12-01 16:58:43 +03:00
int net_help_status ( int argc , const char * * argv )
{
2003-12-01 17:07:22 +03:00
d_printf ( " net status sessions [parseable] "
" Show list of open sessions \n " ) ;
d_printf ( " net status shares [parseable] "
" Show list of open shares \n " ) ;
2003-12-01 16:58:43 +03:00
return - 1 ;
}
2002-04-05 05:36:28 +04:00
static int net_usage ( int argc , const char * * argv )
{
d_printf ( " net time \t \t to view or set time information \n " \
" net lookup \t \t to lookup host name or ip address \n " \
" net user \t \t to manage users \n " \
2002-07-15 14:35:28 +04:00
" net group \t \t to manage groups \n " \
2003-04-19 09:53:55 +04:00
" net groupmap \t \t to manage group mappings \n " \
2005-12-02 23:46:15 +03:00
" net idmap \t \t to manage the idmap id mappings \n " \
2002-04-05 05:36:28 +04:00
" net join \t \t to join a domain \n " \
2002-09-25 19:19:00 +04:00
" net cache \t \t to operate on cache tdb file \n " \
" net getlocalsid [NAME] \t to get the SID for local name \n " \
" net setlocalsid SID \t to set the local domain SID \n " \
2003-08-29 00:24:25 +04:00
" net changesecretpw \t to change the machine password in the local secrets database only \n " \
" \t this requires the -f flag as a safety barrier \n " \
2003-12-01 16:58:43 +03:00
" net status \t \t Show server status \n " \
2004-10-12 15:58:01 +04:00
" net usersidlist \t to get a list of all users with their SIDs \n "
2002-04-05 05:36:28 +04:00
" \n " \
2002-07-15 14:35:28 +04:00
" net ads <command> \t to run ADS commands \n " \
" net rap <command> \t to run RAP (pre-RPC) commands \n " \
" net rpc <command> \t to run RPC commands \n " \
2002-04-05 05:36:28 +04:00
" \n " \
" Type \" net help <option> \" to get more information on that option \n " ) ;
2003-03-18 01:33:34 +03:00
net_common_flags_usage ( argc , argv ) ;
2002-04-05 05:36:28 +04:00
return - 1 ;
}
/*
handle " net help * " subcommands
*/
int net_help ( int argc , const char * * argv )
{
struct functable func [ ] = {
{ " ADS " , net_ads_help } ,
{ " RAP " , net_rap_help } ,
{ " RPC " , net_rpc_help } ,
2002-07-15 14:35:28 +04:00
{ " FILE " , net_help_file } ,
{ " SHARE " , net_help_share } ,
2002-04-05 05:36:28 +04:00
{ " SESSION " , net_rap_session_usage } ,
{ " SERVER " , net_rap_server_usage } ,
{ " DOMAIN " , net_rap_domain_usage } ,
{ " PRINTQ " , net_rap_printq_usage } ,
{ " USER " , net_help_user } ,
2002-07-15 14:35:28 +04:00
{ " GROUP " , net_help_group } ,
2003-04-19 09:53:55 +04:00
{ " GROUPMAP " , net_help_groupmap } ,
2002-11-09 21:01:27 +03:00
{ " JOIN " , net_help_join } ,
2002-04-05 05:36:28 +04:00
{ " VALIDATE " , net_rap_validate_usage } ,
{ " GROUPMEMBER " , net_rap_groupmember_usage } ,
{ " ADMIN " , net_rap_admin_usage } ,
{ " SERVICE " , net_rap_service_usage } ,
{ " PASSWORD " , net_rap_password_usage } ,
{ " TIME " , net_time_usage } ,
{ " LOOKUP " , net_lookup_usage } ,
2004-10-12 15:58:01 +04:00
{ " USERSIDLIST " , net_usersidlist_usage } ,
2003-09-07 20:36:13 +04:00
# ifdef WITH_FAKE_KASERVER
2005-02-10 20:38:49 +03:00
{ " AFS " , net_help_afs } ,
2003-09-07 20:36:13 +04:00
# endif
2005-12-02 23:46:15 +03:00
{ " IDMAP " , net_help_idmap } ,
2002-04-05 05:36:28 +04:00
{ " HELP " , help_usage } ,
{ NULL , NULL } } ;
return net_run_function ( argc , argv , func , net_usage ) ;
}