2 Samba Unix/Linux SMB client library
3 Distributed SMB/CIFS Server Management Utility
4 Copyright (C) 2001 Steve French (sfrench@us.ibm.com)
5 Copyright (C) 2001 Jim McDonough (jmcd@us.ibm.com)
6 Copyright (C) 2001 Andrew Tridgell (tridge@samba.org)
7 Copyright (C) 2001 Andrew Bartlett (abartlet@samba.org)
8 Copyright (C) 2008 Kai Blin (kai@samba.org)
10 Originally written by Steve and Jim. Largely rewritten by tridge in
13 Reworked again by abartlet in December 2001
15 Another overhaul, moving functionality into plug-ins loaded on demand by Kai
18 This program is free software; you can redistribute it and/or modify
19 it under the terms of the GNU General Public License as published by
20 the Free Software Foundation; either version 3 of the License, or
21 (at your option) any later version.
23 This program is distributed in the hope that it will be useful,
24 but WITHOUT ANY WARRANTY; without even the implied warranty of
25 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
26 GNU General Public License for more details.
28 You should have received a copy of the GNU General Public License
29 along with this program. If not, see <http://www.gnu.org/licenses/>. */
31 /*****************************************************/
33 /* Distributed SMB/CIFS Server Management Utility */
35 /* The intent was to make the syntax similar */
36 /* to the NET utility (first developed in DOS */
37 /* with additional interesting & useful functions */
38 /* added in later SMB server network operating */
41 /*****************************************************/
44 #include "popt_common.h"
45 #include "utils/net.h"
47 #include "lib/netapi/netapi.h"
48 #include "../libcli/security/security.h"
52 #ifdef WITH_FAKE_KASERVER
53 #include "utils/net_afs.h"
56 /***********************************************************************/
57 /* end of internationalization section */
58 /***********************************************************************/
60 enum netr_SchannelType
get_sec_channel_type(const char *param
)
62 if (!(param
&& *param
)) {
63 return get_default_sec_channel();
65 if (strequal(param
, "PDC")) {
67 } else if (strequal(param
, "BDC")) {
69 } else if (strequal(param
, "MEMBER")) {
70 return SEC_CHAN_WKSTA
;
72 } else if (strequal(param
, "DOMAIN")) {
73 return SEC_CHAN_DOMAIN
;
76 return get_default_sec_channel();
81 static int net_changetrustpw(struct net_context
*c
, int argc
, const char **argv
)
83 if (net_ads_check_our_domain(c
) == 0)
84 return net_ads_changetrustpw(c
, argc
, argv
);
86 return net_rpc_changetrustpw(c
, argc
, argv
);
89 static void set_line_buffering(FILE *f
)
91 setvbuf(f
, NULL
, _IOLBF
, 0);
94 static int net_changesecretpw(struct net_context
*c
, int argc
,
98 enum netr_SchannelType sec_channel_type
= SEC_CHAN_WKSTA
;
102 set_line_buffering(stdin
);
103 set_line_buffering(stdout
);
104 set_line_buffering(stderr
);
107 trust_pw
= get_pass(_("Enter machine password: "), c
->opt_stdin
);
108 if (trust_pw
== NULL
) {
110 _("Error in reading machine password\n"));
114 if (!secrets_store_machine_password(trust_pw
, lp_workgroup(), sec_channel_type
)) {
116 _("Unable to write the machine account password in the secrets database"));
120 d_printf(_("Modified trust account password in secrets database\n"));
124 d_printf(_("Machine account password change requires the -f flag.\n"
125 "Do NOT use this function unless you know what it does!\n"
126 "This function will change the ADS Domain member "
127 "machine account password in the secrets.tdb file!\n"));
134 * @brief Set the authorised user for winbindd access in secrets.tdb
136 static int net_setauthuser(struct net_context
*c
, int argc
, const char **argv
)
138 const char *password
= NULL
;
140 if (!secrets_init()) {
141 d_fprintf(stderr
, _("Failed to open secrets.tdb.\n"));
145 /* Delete the settings. */
147 if (strncmp(argv
[0], "delete", 6) != 0) {
148 d_fprintf(stderr
,_("Usage:\n"));
150 _(" net setauthuser -U user[%%password] \n"
151 " Set the auth user account to user"
152 "password. Prompt for password if not "
155 _(" net setauthuser delete\n"
156 " Delete the auth user setting.\n"));
159 secrets_delete(SECRETS_AUTH_USER
);
160 secrets_delete(SECRETS_AUTH_DOMAIN
);
161 secrets_delete(SECRETS_AUTH_PASSWORD
);
165 if (!c
->opt_user_specified
) {
166 d_fprintf(stderr
, _("Usage:\n"));
168 _(" net setauthuser -U user[%%password]\n"
169 " Set the auth user account to user"
170 "password. Prompt for password if not "
173 _(" net setauthuser delete\n"
174 " Delete the auth user setting.\n"));
178 password
= net_prompt_pass(c
, _("the auth user"));
179 if (password
== NULL
) {
180 d_fprintf(stderr
,_("Failed to get the auth users password.\n"));
184 if (!secrets_store(SECRETS_AUTH_USER
, c
->opt_user_name
,
185 strlen(c
->opt_user_name
) + 1)) {
186 d_fprintf(stderr
, _("error storing auth user name\n"));
190 if (!secrets_store(SECRETS_AUTH_DOMAIN
, c
->opt_workgroup
,
191 strlen(c
->opt_workgroup
) + 1)) {
192 d_fprintf(stderr
, _("error storing auth user domain\n"));
196 if (!secrets_store(SECRETS_AUTH_PASSWORD
, password
,
197 strlen(password
) + 1)) {
198 d_fprintf(stderr
, _("error storing auth user password\n"));
206 * @brief Get the auth user settings
208 static int net_getauthuser(struct net_context
*c
, int argc
, const char **argv
)
210 char *user
, *domain
, *password
;
212 /* Lift data from secrets file */
214 secrets_fetch_ipc_userpass(&user
, &domain
, &password
);
216 if ((!user
|| !*user
) && (!domain
|| !*domain
) &&
217 (!password
|| !*password
)){
222 d_printf(_("No authorised user configured\n"));
226 /* Pretty print authorised user info */
228 d_printf("%s%s%s%s%s\n", domain
? domain
: "",
229 domain
? lp_winbind_separator(): "", user
,
230 password
? "%" : "", password
? password
: "");
239 Retrieve our local SID or the SID for the specified name
241 static int net_getlocalsid(struct net_context
*c
, int argc
, const char **argv
)
251 name
= lp_netbios_name();
254 if(!initialize_password_db(false, NULL
)) {
255 d_fprintf(stderr
, _("WARNING: Could not open passdb\n"));
259 /* first check to see if we can even access secrets, so we don't
260 panic when we can't. */
262 if (!secrets_init()) {
264 _("Unable to open secrets.tdb. Can't fetch domain "
265 "SID for name: %s\n"), name
);
269 /* Generate one, if it doesn't exist */
270 get_global_sam_sid();
272 if (!secrets_fetch_domain_sid(name
, &sid
)) {
273 DEBUG(0, ("Can't fetch domain SID for name: %s\n", name
));
276 sid_to_fstring(sid_str
, &sid
);
277 d_printf(_("SID for domain %s is: %s\n"), name
, sid_str
);
281 static int net_setlocalsid(struct net_context
*c
, int argc
, const char **argv
)
286 || (strncmp(argv
[0], "S-1-5-21-", strlen("S-1-5-21-")) != 0)
287 || (!string_to_sid(&sid
, argv
[0]))
288 || (sid
.num_auths
!= 4)) {
289 d_printf(_("Usage:"));
290 d_printf(" net setlocalsid S-1-5-21-x-y-z\n");
294 if (!secrets_store_domain_sid(lp_netbios_name(), &sid
)) {
295 DEBUG(0,("Can't store domain SID as a pdc/bdc.\n"));
302 static int net_setdomainsid(struct net_context
*c
, int argc
, const char **argv
)
307 || (strncmp(argv
[0], "S-1-5-21-", strlen("S-1-5-21-")) != 0)
308 || (!string_to_sid(&sid
, argv
[0]))
309 || (sid
.num_auths
!= 4)) {
310 d_printf(_("Usage:"));
311 d_printf(" net setdomainsid S-1-5-21-x-y-z\n");
315 if (!secrets_store_domain_sid(lp_workgroup(), &sid
)) {
316 DEBUG(0,("Can't store domain SID.\n"));
323 static int net_getdomainsid(struct net_context
*c
, int argc
, const char **argv
)
325 struct dom_sid domain_sid
;
329 d_printf(_("Usage:"));
330 d_printf(" net getdomainsid\n");
334 if(!initialize_password_db(false, NULL
)) {
335 d_fprintf(stderr
, _("WARNING: Could not open passdb\n"));
339 /* first check to see if we can even access secrets, so we don't
340 panic when we can't. */
342 if (!secrets_init()) {
343 d_fprintf(stderr
, _("Unable to open secrets.tdb. Can't fetch "
344 "domain SID for name: %s\n"),
345 get_global_sam_name());
349 /* Generate one, if it doesn't exist */
350 get_global_sam_sid();
353 if (!secrets_fetch_domain_sid(lp_netbios_name(), &domain_sid
)) {
354 d_fprintf(stderr
, _("Could not fetch local SID\n"));
357 sid_to_fstring(sid_str
, &domain_sid
);
358 d_printf(_("SID for local machine %s is: %s\n"),
359 lp_netbios_name(), sid_str
);
361 if (!secrets_fetch_domain_sid(c
->opt_workgroup
, &domain_sid
)) {
362 d_fprintf(stderr
, _("Could not fetch domain SID\n"));
366 sid_to_fstring(sid_str
, &domain_sid
);
367 d_printf(_("SID for domain %s is: %s\n"), c
->opt_workgroup
, sid_str
);
372 static bool search_maxrid(struct pdb_search
*search
, const char *type
,
375 struct samr_displayentry
*entries
;
376 uint32_t i
, num_entries
;
378 if (search
== NULL
) {
379 d_fprintf(stderr
, _("get_maxrid: Could not search %s\n"), type
);
383 num_entries
= pdb_search_entries(search
, 0, 0xffffffff, &entries
);
384 for (i
=0; i
<num_entries
; i
++)
385 *max_rid
= MAX(*max_rid
, entries
[i
].rid
);
390 static uint32_t get_maxrid(void)
392 uint32_t max_rid
= 0;
394 if (!search_maxrid(pdb_search_users(talloc_tos(), 0), "users", &max_rid
))
397 if (!search_maxrid(pdb_search_groups(talloc_tos()), "groups", &max_rid
))
400 if (!search_maxrid(pdb_search_aliases(talloc_tos(),
401 get_global_sam_sid()),
402 "aliases", &max_rid
))
408 static int net_maxrid(struct net_context
*c
, int argc
, const char **argv
)
413 d_fprintf(stderr
, "%s net maxrid\n", _("Usage:"));
417 if ((rid
= get_maxrid()) == 0) {
418 d_fprintf(stderr
, _("can't get current maximum rid\n"));
422 d_printf(_("Currently used maximum rid: %d\n"), rid
);
427 /* main function table */
428 static struct functable net_func
[] = {
433 N_("Run functions using RPC transport"),
434 N_(" Use 'net help rpc' to get more extensive information "
435 "about 'net rpc' commands.")
441 N_("Run functions using RAP transport"),
442 N_(" Use 'net help rap' to get more extensive information "
443 "about 'net rap' commands.")
449 N_("Run functions using ADS transport"),
450 N_(" Use 'net help ads' to get more extensive information "
451 "about 'net ads' commands.")
454 /* eventually these should auto-choose the transport ... */
458 NET_TRANSPORT_RPC
| NET_TRANSPORT_RAP
,
459 N_("Functions on remote opened files"),
460 N_(" Use 'net help file' to get more information about 'net "
466 NET_TRANSPORT_RPC
| NET_TRANSPORT_RAP
,
467 N_("Functions on shares"),
468 N_(" Use 'net help share' to get more information about 'net "
475 N_("Manage sessions"),
476 N_(" Use 'net help session' to get more information about "
477 "'net session' commands.")
483 N_("List servers in workgroup"),
484 N_(" Use 'net help server' to get more information about 'net "
491 N_("List domains/workgroups on network"),
492 N_(" Use 'net help domain' to get more information about 'net "
499 N_("Modify printer queue"),
500 N_(" Use 'net help printq' to get more information about 'net "
506 NET_TRANSPORT_ADS
| NET_TRANSPORT_RPC
| NET_TRANSPORT_RAP
,
508 N_(" Use 'net help user' to get more information about 'net "
514 NET_TRANSPORT_ADS
| NET_TRANSPORT_RPC
| NET_TRANSPORT_RAP
,
516 N_(" Use 'net help group' to get more information about 'net "
523 N_("Manage group mappings"),
524 N_(" Use 'net help groupmap' to get more information about "
525 "'net groupmap' commands.")
531 N_("Functions on the SAM database"),
532 N_(" Use 'net help sam' to get more information about 'net "
539 N_("Validate username and password"),
540 N_(" Use 'net help validate' to get more information about "
541 "'net validate' commands.")
547 N_("Modify group memberships"),
548 N_(" Use 'net help groupmember' to get more information about "
549 "'net groupmember' commands.")
554 N_("Execute remote command on a remote OS/2 server"),
555 N_(" Use 'net help admin' to get more information about 'net "
561 N_("List/modify running services"),
562 N_(" Use 'net help service' to get more information about "
563 "'net service' commands.")
569 N_("Change user password on target server"),
570 N_(" Use 'net help password' to get more information about "
571 "'net password' commands.")
575 NET_TRANSPORT_ADS
| NET_TRANSPORT_RPC
,
576 N_("Change the trust password"),
577 N_(" Use 'net help changetrustpw' to get more information "
578 "about 'net changetrustpw'.")
583 N_("Change the secret password"),
584 N_(" net [options] changesecretpw\n"
585 " Change the ADS domain member machine account password "
587 " Do NOT use this function unless you know what it does.\n"
588 " Requires the -f flag to work.")
594 N_("Set the winbind auth user"),
595 N_(" net -U user[%%password] [-W domain] setauthuser\n"
596 " Set the auth user, password (and optionally domain\n"
597 " Will prompt for password if not given.\n"
598 " net setauthuser delete\n"
599 " Delete the existing auth user settings.")
605 N_("Get the winbind auth user settings"),
606 N_(" net getauthuser\n"
607 " Get the current winbind auth user settings.")
613 N_(" Use 'net help time' to get more information about 'net "
619 N_("Look up host names/IP addresses"),
620 N_(" Use 'net help lookup' to get more information about 'net "
626 N_("Manipulate the global lock table"),
627 N_(" Use 'net help g_lock' to get more information about "
628 "'net g_lock' commands.")
632 NET_TRANSPORT_ADS
| NET_TRANSPORT_RPC
,
633 N_("Join a domain/AD"),
634 N_(" Use 'net help join' to get more information about 'net "
640 N_("Join/unjoin (remote) machines to/from a domain/AD"),
641 N_(" Use 'net help dom' to get more information about 'net "
647 N_("Operate on the cache tdb file"),
648 N_(" Use 'net help cache' to get more information about 'net "
654 N_("Get the SID for the local domain"),
655 N_(" net getlocalsid")
660 N_("Set the SID for the local domain"),
661 N_(" net setlocalsid S-1-5-21-x-y-z")
666 N_("Set domain SID on member servers"),
667 N_(" net setdomainsid S-1-5-21-x-y-z")
672 N_("Get domain SID on member servers"),
673 N_(" net getdomainsid")
678 N_("Display the maximum RID currently used"),
684 N_("IDmap functions"),
685 N_(" Use 'net help idmap to get more information about 'net "
691 N_("Display server status"),
692 N_(" Use 'net help status' to get more information about 'net "
698 N_("Manage user-modifiable shares"),
699 N_(" Use 'net help usershare to get more information about "
700 "'net usershare' commands.")
705 N_("Display list of all users with SID"),
706 N_(" Use 'net help usersidlist' to get more information about "
707 "'net usersidlist'.")
712 N_("Manage Samba registry based configuration"),
713 N_(" Use 'net help conf' to get more information about 'net "
719 N_("Manage the Samba registry"),
720 N_(" Use 'net help registry' to get more information about "
721 "'net registry' commands.")
726 N_("Process Win32 *.evt eventlog files"),
727 N_(" Use 'net help eventlog' to get more information about "
728 "'net eventlog' commands.")
733 N_("Process tdb printer files"),
734 N_(" Use 'net help printing' to get more information about "
735 "'net printing' commands.")
741 N_("Manage the serverid tdb"),
742 N_(" Use 'net help serverid' to get more information about "
743 "'net serverid' commands.")
746 #ifdef WITH_FAKE_KASERVER
750 N_("Manage AFS tokens"),
751 N_(" Use 'net help afs' to get more information about 'net "
759 N_("Print usage information"),
760 N_(" Use 'net help help' to list usage information for 'net' "
763 {NULL
, NULL
, 0, NULL
, NULL
}
767 /****************************************************************************
769 ****************************************************************************/
770 int main(int argc
, char **argv
)
776 const char ** argv_new
;
777 const char **argv_const
= discard_const_p(const char *, argv
);
779 TALLOC_CTX
*frame
= talloc_stackframe();
780 struct net_context
*c
= talloc_zero(frame
, struct net_context
);
782 struct poptOption long_options
[] = {
783 {"help", 'h', POPT_ARG_NONE
, 0, 'h'},
784 {"workgroup", 'w', POPT_ARG_STRING
, &c
->opt_target_workgroup
},
785 {"user", 'U', POPT_ARG_STRING
, &c
->opt_user_name
, 'U'},
786 {"ipaddress", 'I', POPT_ARG_STRING
, 0,'I'},
787 {"port", 'p', POPT_ARG_INT
, &c
->opt_port
},
788 {"myname", 'n', POPT_ARG_STRING
, &c
->opt_requester_name
},
789 {"server", 'S', POPT_ARG_STRING
, &c
->opt_host
},
790 {"encrypt", 'e', POPT_ARG_NONE
, NULL
, 'e', N_("Encrypt SMB transport (UNIX extended servers only)") },
791 {"container", 'c', POPT_ARG_STRING
, &c
->opt_container
},
792 {"comment", 'C', POPT_ARG_STRING
, &c
->opt_comment
},
793 {"maxusers", 'M', POPT_ARG_INT
, &c
->opt_maxusers
},
794 {"flags", 'F', POPT_ARG_INT
, &c
->opt_flags
},
795 {"long", 'l', POPT_ARG_NONE
, &c
->opt_long_list_entries
},
796 {"reboot", 'r', POPT_ARG_NONE
, &c
->opt_reboot
},
797 {"force", 'f', POPT_ARG_NONE
, &c
->opt_force
},
798 {"stdin", 'i', POPT_ARG_NONE
, &c
->opt_stdin
},
799 {"timeout", 't', POPT_ARG_INT
, &c
->opt_timeout
},
800 {"request-timeout",0,POPT_ARG_INT
, &c
->opt_request_timeout
},
801 {"machine-pass",'P', POPT_ARG_NONE
, &c
->opt_machine_pass
},
802 {"kerberos", 'k', POPT_ARG_NONE
, &c
->opt_kerberos
},
803 {"myworkgroup", 'W', POPT_ARG_STRING
, &c
->opt_workgroup
},
804 {"use-ccache", 0, POPT_ARG_NONE
, &c
->opt_ccache
},
805 {"verbose", 'v', POPT_ARG_NONE
, &c
->opt_verbose
},
806 {"test", 'T', POPT_ARG_NONE
, &c
->opt_testmode
},
807 /* Options for 'net groupmap set' */
808 {"local", 'L', POPT_ARG_NONE
, &c
->opt_localgroup
},
809 {"domain", 'D', POPT_ARG_NONE
, &c
->opt_domaingroup
},
810 {"ntname", 'N', POPT_ARG_STRING
, &c
->opt_newntname
},
811 {"rid", 'R', POPT_ARG_INT
, &c
->opt_rid
},
812 /* Options for 'net rpc share migrate' */
813 {"acls", 0, POPT_ARG_NONE
, &c
->opt_acls
},
814 {"attrs", 0, POPT_ARG_NONE
, &c
->opt_attrs
},
815 {"timestamps", 0, POPT_ARG_NONE
, &c
->opt_timestamps
},
816 {"exclude", 'X', POPT_ARG_STRING
, &c
->opt_exclude
},
817 {"destination", 0, POPT_ARG_STRING
, &c
->opt_destination
},
818 {"tallocreport", 0, POPT_ARG_NONE
, &c
->do_talloc_report
},
819 /* Options for 'net rpc vampire (keytab)' */
820 {"force-full-repl", 0, POPT_ARG_NONE
, &c
->opt_force_full_repl
},
821 {"single-obj-repl", 0, POPT_ARG_NONE
, &c
->opt_single_obj_repl
},
822 {"clean-old-entries", 0, POPT_ARG_NONE
, &c
->opt_clean_old_entries
},
823 /* Options for 'net idmap'*/
824 {"db", 0, POPT_ARG_STRING
, &c
->opt_db
},
825 {"lock", 0, POPT_ARG_NONE
, &c
->opt_lock
},
826 {"auto", 'a', POPT_ARG_NONE
, &c
->opt_auto
},
827 {"repair", 0, POPT_ARG_NONE
, &c
->opt_repair
},
828 /* Options for 'net registry check'*/
829 {"reg-version", 0, POPT_ARG_INT
, &c
->opt_reg_version
},
830 {"output", 'o', POPT_ARG_STRING
, &c
->opt_output
},
831 {"wipe", 0, POPT_ARG_NONE
, &c
->opt_wipe
},
832 /* Options for 'net registry import' */
833 {"precheck", 0, POPT_ARG_STRING
, &c
->opt_precheck
},
838 zero_sockaddr(&c
->opt_dest_ip
);
840 setup_logging(argv
[0], DEBUG_STDERR
);
844 setlocale(LC_ALL
, "");
845 #if defined(HAVE_BINDTEXTDOMAIN)
846 bindtextdomain(MODULE_NAME
, get_dyn_LOCALEDIR());
848 #if defined(HAVE_TEXTDOMAIN)
849 textdomain(MODULE_NAME
);
852 /* set default debug level to 0 regardless of what smb.conf sets */
853 lp_set_cmdline("log level", "0");
854 c
->private_data
= net_func
;
856 pc
= poptGetContext(NULL
, argc
, argv_const
, long_options
,
857 POPT_CONTEXT_KEEP_FIRST
);
859 while((opt
= poptGetNextOpt(pc
)) != -1) {
862 c
->display_usage
= true;
865 c
->smb_encrypt
= true;
868 if (!interpret_string_addr(&c
->opt_dest_ip
,
869 poptGetOptArg(pc
), 0)) {
870 d_fprintf(stderr
, _("\nInvalid ip address specified\n"));
872 c
->opt_have_ip
= true;
876 c
->opt_user_specified
= true;
877 c
->opt_user_name
= talloc_strdup(c
, c
->opt_user_name
);
878 p
= strchr(c
->opt_user_name
,'%');
881 c
->opt_password
= p
+1;
885 d_fprintf(stderr
, _("\nInvalid option %s: %s\n"),
886 poptBadOption(pc
, 0), poptStrerror(opt
));
887 net_help(c
, argc
, argv_const
);
892 if (!lp_load_initial_only(get_dyn_CONFIGFILE())) {
893 d_fprintf(stderr
, "Can't load %s - run testparm to debug it\n",
894 get_dyn_CONFIGFILE());
899 * Failing to init the msg_ctx isn't a fatal error. Only root-level
900 * things (joining/leaving domains etc.) will be denied.
902 c
->msg_ctx
= messaging_init(c
, samba_tevent_context_init(c
));
904 if (!lp_load_global(get_dyn_CONFIGFILE())) {
905 d_fprintf(stderr
, "Can't load %s - run testparm to debug it\n",
906 get_dyn_CONFIGFILE());
910 #if defined(HAVE_BIND_TEXTDOMAIN_CODESET)
911 /* Bind our gettext results to 'unix charset'
913 This ensures that the translations and any embedded strings are in the
914 same charset. It won't be the one from the user's locale (we no
915 longer auto-detect that), but it will be self-consistent.
917 bind_textdomain_codeset(MODULE_NAME
, lp_unix_charset());
920 argv_new
= (const char **)poptGetArgs(pc
);
923 for (i
=0; i
<argc
; i
++) {
924 if (argv_new
[i
] == NULL
) {
930 if (c
->do_talloc_report
) {
931 talloc_enable_leak_report();
934 if (c
->opt_requester_name
) {
935 lp_set_cmdline("netbios name", c
->opt_requester_name
);
938 if (!c
->opt_user_name
&& getenv("LOGNAME")) {
939 c
->opt_user_name
= getenv("LOGNAME");
942 if (!c
->opt_workgroup
) {
943 c
->opt_workgroup
= smb_xstrdup(lp_workgroup());
946 if (!c
->opt_target_workgroup
) {
947 c
->opt_target_workgroup
= smb_xstrdup(lp_workgroup());
955 /* this makes sure that when we do things like call scripts,
956 that it won't assert because we are not root */
959 if (c
->opt_machine_pass
) {
960 /* it is very useful to be able to make ads queries as the
961 machine account for testing purposes and for domain leave */
963 net_use_krb_machine_account(c
);
966 if (!c
->opt_password
) {
967 c
->opt_password
= getenv("PASSWD");
970 popt_burn_cmdline_password(argc
, argv
);
972 rc
= net_run_function(c
, argc_new
-1, argv_new
+1, "net", net_func
);
974 DEBUG(2,("return code = %d\n", rc
));
976 gencache_stabilize();
978 libnetapi_free(c
->netapi_ctx
);