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"
2002-07-15 14:35:28 +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-04-14 08:00:37 +04:00
d_printf ( " \t -d or --debuglevel=<level> \t \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-04-14 08:00:37 +04:00
d_printf ( " \t -s or --configfile=<path> \t \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 " \
" CHANGESCRETPW \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 " ) ;
2003-01-15 19:10:57 +03:00
d_printf ( " \n net [<method>] user ADD <name> [password] [-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 " ) ;
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 " ) ;
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 " ) ;
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-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] "
" \n \t Adds a share from a server (makes the export active) \n \n "
" net [<method>] share DELETE <sharename> [misc. options] [targets] \n "
2002-07-15 14:35:28 +04:00
" \n \t Deletes a share from a server (makes the export inactive) \n " ) ;
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 "
" \t -M or --maxusers=<num> \t \t max users allowed for share \n " ) ;
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 ;
}
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 " \
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 " \
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 } ,
{ " HELP " , help_usage } ,
{ NULL , NULL } } ;
return net_run_function ( argc , argv , func , net_usage ) ;
}