2 Samba Unix/Linux SMB client library
4 Copyright (C) 2001 Andrew Tridgell (tridge@samba.org)
5 Copyright (C) 2001 Remus Koos (remuskoos@yahoo.com)
6 Copyright (C) 2002 Jim McDonough (jmcd@us.ibm.com)
8 This program is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 2 of the License, or
11 (at your option) any later version.
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with this program; if not, write to the Free Software
20 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
24 #include "../utils/net.h"
28 int net_ads_usage(int argc, const char **argv)
31 "\nnet ads join <org_unit>"\
32 "\n\tjoins the local machine to a ADS realm\n"\
34 "\n\tremoves the local machine from a ADS realm\n"\
36 "\n\ttests that an exiting join is OK\n"\
38 "\n\tlist, add, or delete users in the realm\n"\
40 "\n\tlist, add, or delete groups in the realm\n"\
42 "\n\tshows some info on the server\n"\
44 "\n\tdump the machine account details to stdout\n"
46 "\n\tperform a CLDAP search on the server\n"
47 "\nnet ads password <username@realm> -Uadmin_username@realm%%admin_pass"\
48 "\n\tchange a user's password using an admin account"\
49 "\n\t(note: use realm in UPPERCASE)\n"\
50 "\nnet ads chostpass"\
51 "\n\tchange the trust account password of this machine in the AD tree\n"\
52 "\nnet ads printer [info | publish | remove] <printername> <servername>"\
53 "\n\t lookup, add, or remove directory entry for a printer\n"\
55 "\n\tperform a raw LDAP search and dump the results\n"
57 "\n\tperform a raw LDAP search and dump attributes of a particular DN\n"
64 this implements the CLDAP based netlogon lookup requests
65 for finding the domain controller of a ADS domain
67 static int net_ads_lookup(int argc, const char **argv)
71 ads = ads_init(NULL, NULL, opt_host);
73 ads->auth.flags |= ADS_AUTH_NO_BIND;
78 if (!ads || !ads->config.realm) {
79 d_printf("Didn't find the cldap server!\n");
83 return ads_cldap_netlogon(ads);
88 static int net_ads_info(int argc, const char **argv)
92 ads = ads_init(NULL, NULL, opt_host);
95 ads->auth.flags |= ADS_AUTH_NO_BIND;
100 if (!ads || !ads->config.realm) {
101 d_printf("Didn't find the ldap server!\n");
105 d_printf("LDAP server: %s\n", inet_ntoa(ads->ldap_ip));
106 d_printf("LDAP server name: %s\n", ads->config.ldap_server_name);
107 d_printf("Realm: %s\n", ads->config.realm);
108 d_printf("Bind Path: %s\n", ads->config.bind_path);
109 d_printf("LDAP port: %d\n", ads->ldap_port);
110 d_printf("Server time: %s\n", http_timestring(ads->config.current_time));
115 static void use_in_memory_ccache(void) {
116 /* Use in-memory credentials cache so we do not interfere with
117 * existing credentials */
118 setenv(KRB5_ENV_CCNAME, "MEMORY:net_ads", 1);
121 static ADS_STRUCT *ads_startup(void)
125 BOOL need_password = False;
126 BOOL second_time = False;
129 ads = ads_init(NULL, NULL, opt_host);
131 if (!opt_user_name) {
132 opt_user_name = "administrator";
135 if (opt_user_specified) {
136 need_password = True;
140 if (!opt_password && need_password) {
142 asprintf(&prompt,"%s password: ", opt_user_name);
143 opt_password = getpass(prompt);
148 use_in_memory_ccache();
149 ads->auth.password = strdup(opt_password);
152 ads->auth.user_name = strdup(opt_user_name);
155 * If the username is of the form "name@realm",
156 * extract the realm and convert to upper case.
158 if ((realm = strchr(ads->auth.user_name, '@'))) {
160 ads->auth.realm = strdup(realm);
161 strupper(ads->auth.realm);
164 status = ads_connect(ads);
165 if (!ADS_ERR_OK(status)) {
166 if (!need_password && !second_time) {
167 need_password = True;
171 DEBUG(1,("ads_connect: %s\n", ads_errstr(status)));
180 Check to see if connection can be made via ads.
181 ads_startup() stores the password in opt_password if it needs to so
182 that rpc or rap can use it without re-prompting.
184 int net_ads_check(void)
196 determine the netbios workgroup name for a domain
198 static int net_ads_workgroup(int argc, const char **argv)
204 if (!(ads = ads_startup())) return -1;
206 if (!(ctx = talloc_init("net_ads_workgroup"))) {
210 if (!ADS_ERR_OK(ads_workgroup_name(ads, ctx, &workgroup))) {
211 d_printf("Failed to find workgroup for realm '%s'\n",
217 d_printf("Workgroup: %s\n", workgroup);
226 static BOOL usergrp_display(char *field, void **values, void *data_area)
228 char **disp_fields = (char **) data_area;
230 if (!field) { /* must be end of record */
231 if (!strchr_m(disp_fields[0], '$')) {
233 d_printf("%-21.21s %-50.50s\n",
234 disp_fields[0], disp_fields[1]);
236 d_printf("%s\n", disp_fields[0]);
238 SAFE_FREE(disp_fields[0]);
239 SAFE_FREE(disp_fields[1]);
242 if (!values) /* must be new field, indicate string field */
244 if (StrCaseCmp(field, "sAMAccountName") == 0) {
245 disp_fields[0] = strdup((char *) values[0]);
247 if (StrCaseCmp(field, "description") == 0)
248 disp_fields[1] = strdup((char *) values[0]);
252 static int net_ads_user_usage(int argc, const char **argv)
254 return net_help_user(argc, argv);
257 static int ads_user_add(int argc, const char **argv)
265 if (argc < 1) return net_ads_user_usage(argc, argv);
267 if (!(ads = ads_startup())) return -1;
269 status = ads_find_user_acct(ads, &res, argv[0]);
271 if (!ADS_ERR_OK(status)) {
272 d_printf("ads_user_add: %s\n", ads_errstr(status));
276 if (ads_count_replies(ads, res)) {
277 d_printf("ads_user_add: User %s already exists\n", argv[0]);
281 status = ads_add_user_acct(ads, argv[0], opt_container, opt_comment);
283 if (!ADS_ERR_OK(status)) {
284 d_printf("Could not add user %s: %s\n", argv[0],
289 /* if no password is to be set, we're done */
291 d_printf("User %s added\n", argv[0]);
296 /* try setting the password */
297 asprintf(&upn, "%s@%s", argv[0], ads->config.realm);
298 status = krb5_set_password(ads->auth.kdc_server, upn, argv[1], ads->auth.time_offset);
300 if (ADS_ERR_OK(status)) {
301 d_printf("User %s added\n", argv[0]);
306 /* password didn't set, delete account */
307 d_printf("Could not add user %s. Error setting password %s\n",
308 argv[0], ads_errstr(status));
309 ads_msgfree(ads, res);
310 status=ads_find_user_acct(ads, &res, argv[0]);
311 if (ADS_ERR_OK(status)) {
312 userdn = ads_get_dn(ads, res);
313 ads_del_dn(ads, userdn);
314 ads_memfree(ads, userdn);
319 ads_msgfree(ads, res);
324 static int ads_user_info(int argc, const char **argv)
329 const char *attrs[] = {"memberOf", NULL};
330 char *searchstring=NULL;
332 char *escaped_user = escape_ldap_string_alloc(argv[0]);
334 if (argc < 1) return net_ads_user_usage(argc, argv);
336 if (!(ads = ads_startup())) return -1;
339 d_printf("ads_user_info: failed to escape user %s\n", argv[0]);
343 asprintf(&searchstring, "(sAMAccountName=%s)", escaped_user);
344 rc = ads_search(ads, &res, searchstring, attrs);
345 safe_free(searchstring);
347 if (!ADS_ERR_OK(rc)) {
348 d_printf("ads_search: %s\n", ads_errstr(rc));
352 grouplist = ldap_get_values(ads->ld, res, "memberOf");
357 for (i=0;grouplist[i];i++) {
358 groupname = ldap_explode_dn(grouplist[i], 1);
359 d_printf("%s\n", groupname[0]);
360 ldap_value_free(groupname);
362 ldap_value_free(grouplist);
365 ads_msgfree(ads, res);
371 static int ads_user_delete(int argc, const char **argv)
378 if (argc < 1) return net_ads_user_usage(argc, argv);
380 if (!(ads = ads_startup())) return -1;
382 rc = ads_find_user_acct(ads, &res, argv[0]);
383 if (!ADS_ERR_OK(rc)) {
384 DEBUG(0, ("User %s does not exist\n", argv[0]));
387 userdn = ads_get_dn(ads, res);
388 ads_msgfree(ads, res);
389 rc = ads_del_dn(ads, userdn);
390 ads_memfree(ads, userdn);
391 if (!ADS_ERR_OK(rc)) {
392 d_printf("User %s deleted\n", argv[0]);
395 d_printf("Error deleting user %s: %s\n", argv[0],
400 int net_ads_user(int argc, const char **argv)
402 struct functable func[] = {
403 {"ADD", ads_user_add},
404 {"INFO", ads_user_info},
405 {"DELETE", ads_user_delete},
410 const char *shortattrs[] = {"sAMAccountName", NULL};
411 const char *longattrs[] = {"sAMAccountName", "description", NULL};
412 char *disp_fields[2] = {NULL, NULL};
415 if (!(ads = ads_startup())) return -1;
417 if (opt_long_list_entries)
418 d_printf("\nUser name Comment"\
419 "\n-----------------------------\n");
421 rc = ads_do_search_all_fn(ads, ads->config.bind_path,
423 "(objectclass=user)",
424 opt_long_list_entries ? longattrs :
425 shortattrs, usergrp_display,
431 return net_run_function(argc, argv, func, net_ads_user_usage);
434 static int net_ads_group_usage(int argc, const char **argv)
436 return net_help_group(argc, argv);
439 static int ads_group_add(int argc, const char **argv)
446 if (argc < 1) return net_ads_group_usage(argc, argv);
448 if (!(ads = ads_startup())) return -1;
450 status = ads_find_user_acct(ads, &res, argv[0]);
452 if (!ADS_ERR_OK(status)) {
453 d_printf("ads_group_add: %s\n", ads_errstr(status));
457 if (ads_count_replies(ads, res)) {
458 d_printf("ads_group_add: Group %s already exists\n", argv[0]);
459 ads_msgfree(ads, res);
463 status = ads_add_group_acct(ads, argv[0], opt_container, opt_comment);
465 if (ADS_ERR_OK(status)) {
466 d_printf("Group %s added\n", argv[0]);
469 d_printf("Could not add group %s: %s\n", argv[0],
475 ads_msgfree(ads, res);
480 static int ads_group_delete(int argc, const char **argv)
487 if (argc < 1) return net_ads_group_usage(argc, argv);
489 if (!(ads = ads_startup())) return -1;
491 rc = ads_find_user_acct(ads, &res, argv[0]);
492 if (!ADS_ERR_OK(rc)) {
493 DEBUG(0, ("Group %s does not exist\n", argv[0]));
496 groupdn = ads_get_dn(ads, res);
497 ads_msgfree(ads, res);
498 rc = ads_del_dn(ads, groupdn);
499 ads_memfree(ads, groupdn);
500 if (!ADS_ERR_OK(rc)) {
501 d_printf("Group %s deleted\n", argv[0]);
504 d_printf("Error deleting group %s: %s\n", argv[0],
509 int net_ads_group(int argc, const char **argv)
511 struct functable func[] = {
512 {"ADD", ads_group_add},
513 {"DELETE", ads_group_delete},
518 const char *shortattrs[] = {"sAMAccountName", NULL};
519 const char *longattrs[] = {"sAMAccountName", "description", NULL};
520 char *disp_fields[2] = {NULL, NULL};
523 if (!(ads = ads_startup())) return -1;
525 if (opt_long_list_entries)
526 d_printf("\nGroup name Comment"\
527 "\n-----------------------------\n");
528 rc = ads_do_search_all_fn(ads, ads->config.bind_path,
530 "(objectclass=group)",
531 opt_long_list_entries ? longattrs :
532 shortattrs, usergrp_display,
538 return net_run_function(argc, argv, func, net_ads_group_usage);
541 static int net_ads_status(int argc, const char **argv)
547 if (!(ads = ads_startup())) return -1;
549 rc = ads_find_machine_acct(ads, &res, global_myname());
550 if (!ADS_ERR_OK(rc)) {
551 d_printf("ads_find_machine_acct: %s\n", ads_errstr(rc));
555 if (ads_count_replies(ads, res) == 0) {
556 d_printf("No machine account for '%s' found\n", global_myname());
565 static int net_ads_leave(int argc, const char **argv)
567 ADS_STRUCT *ads = NULL;
570 if (!secrets_init()) {
571 DEBUG(1,("Failed to initialise secrets database\n"));
577 asprintf(&user_name, "%s$", global_myname());
578 opt_password = secrets_fetch_machine_password();
579 opt_user_name = user_name;
582 if (!(ads = ads_startup())) {
586 rc = ads_leave_realm(ads, global_myname());
587 if (!ADS_ERR_OK(rc)) {
588 d_printf("Failed to delete host '%s' from the '%s' realm.\n",
589 global_myname(), ads->config.realm);
593 d_printf("Removed '%s' from realm '%s'\n", global_myname(), ads->config.realm);
598 static int net_ads_join_ok(void)
601 ADS_STRUCT *ads = NULL;
603 if (!secrets_init()) {
604 DEBUG(1,("Failed to initialise secrets database\n"));
608 asprintf(&user_name, "%s$", global_myname());
609 opt_user_name = user_name;
610 opt_password = secrets_fetch_machine_password();
612 if (!(ads = ads_startup())) {
621 check that an existing join is OK
623 int net_ads_testjoin(int argc, const char **argv)
625 use_in_memory_ccache();
627 /* Display success or failure */
628 if (net_ads_join_ok() != 0) {
629 fprintf(stderr,"Join to domain is not valid\n");
633 printf("Join is OK\n");
638 join a domain using ADS
640 int net_ads_join(int argc, const char **argv)
646 const char *org_unit = "Computers";
652 if (argc > 0) org_unit = argv[0];
654 if (!secrets_init()) {
655 DEBUG(1,("Failed to initialise secrets database\n"));
659 tmp_password = generate_random_str(DEFAULT_TRUST_ACCOUNT_PASSWORD_LENGTH);
660 password = strdup(tmp_password);
662 if (!(ads = ads_startup())) return -1;
664 ou_str = ads_ou_string(org_unit);
665 asprintf(&dn, "%s,%s", ou_str, ads->config.bind_path);
668 rc = ads_search_dn(ads, &res, dn, NULL);
669 ads_msgfree(ads, res);
671 if (rc.error_type == ADS_ERROR_LDAP && rc.err.rc == LDAP_NO_SUCH_OBJECT) {
672 d_printf("ads_join_realm: organizational unit %s does not exist (dn:%s)\n",
678 if (!ADS_ERR_OK(rc)) {
679 d_printf("ads_join_realm: %s\n", ads_errstr(rc));
683 rc = ads_join_realm(ads, global_myname(), org_unit);
684 if (!ADS_ERR_OK(rc)) {
685 d_printf("ads_join_realm: %s\n", ads_errstr(rc));
689 rc = ads_domain_sid(ads, &dom_sid);
690 if (!ADS_ERR_OK(rc)) {
691 d_printf("ads_domain_sid: %s\n", ads_errstr(rc));
695 rc = ads_set_machine_password(ads, global_myname(), password);
696 if (!ADS_ERR_OK(rc)) {
697 d_printf("ads_set_machine_password: %s\n", ads_errstr(rc));
701 if (!secrets_store_domain_sid(lp_workgroup(), &dom_sid)) {
702 DEBUG(1,("Failed to save domain sid\n"));
706 if (!secrets_store_machine_password(password)) {
707 DEBUG(1,("Failed to save machine password\n"));
711 d_printf("Joined '%s' to realm '%s'\n", global_myname(), ads->config.realm);
718 int net_ads_printer_usage(int argc, const char **argv)
721 "\nnet ads printer info <printer> <server>"
722 "\n\tlookup info in directory for printer on server"
723 "\n\t(note: printer defaults to \"*\", server defaults to local)\n"
724 "\nnet ads printer publish <printername>"
725 "\n\tpublish printer in directory"
726 "\n\t(note: printer name is required)\n"
727 "\nnet ads printer remove <printername>"
728 "\n\tremove printer from directory"
729 "\n\t(note: printer name is required)\n");
733 static int net_ads_printer_info(int argc, const char **argv)
737 const char *servername, *printername;
740 if (!(ads = ads_startup())) return -1;
743 printername = argv[0];
748 servername = argv[1];
750 servername = global_myname();
752 rc = ads_find_printer_on_server(ads, &res, printername, servername);
754 if (!ADS_ERR_OK(rc)) {
755 d_printf("ads_find_printer_on_server: %s\n", ads_errstr(rc));
756 ads_msgfree(ads, res);
760 if (ads_count_replies(ads, res) == 0) {
761 d_printf("Printer '%s' not found\n", printername);
762 ads_msgfree(ads, res);
767 ads_msgfree(ads, res);
772 void do_drv_upgrade_printer(int msg_type, pid_t src, void *buf, size_t len)
777 static int net_ads_printer_publish(int argc, const char **argv)
781 const char *servername;
782 struct cli_state *cli;
783 struct in_addr server_ip;
785 TALLOC_CTX *mem_ctx = talloc_init("net_ads_printer_publish");
786 ADS_MODLIST mods = ads_init_mods(mem_ctx);
787 char *prt_dn, *srv_dn, **srv_cn;
790 if (!(ads = ads_startup())) return -1;
793 return net_ads_printer_usage(argc, argv);
796 servername = argv[1];
798 servername = global_myname();
800 ads_find_machine_acct(ads, &res, servername);
801 srv_dn = ldap_get_dn(ads->ld, res);
802 srv_cn = ldap_explode_dn(srv_dn, 1);
803 asprintf(&prt_dn, "cn=%s-%s,%s", srv_cn[0], argv[0], srv_dn);
805 resolve_name(servername, &server_ip, 0x20);
807 nt_status = cli_full_connection(&cli, global_myname(), servername,
810 opt_user_name, opt_workgroup,
811 opt_password ? opt_password : "",
812 CLI_FULL_CONNECTION_USE_KERBEROS,
815 cli_nt_session_open(cli, PI_SPOOLSS);
816 get_remote_printer_publishing_data(cli, mem_ctx, &mods, argv[0]);
818 rc = ads_add_printer_entry(ads, prt_dn, mem_ctx, &mods);
819 if (!ADS_ERR_OK(rc)) {
820 d_printf("ads_publish_printer: %s\n", ads_errstr(rc));
824 d_printf("published printer\n");
829 static int net_ads_printer_remove(int argc, const char **argv)
833 const char *servername;
837 if (!(ads = ads_startup())) return -1;
840 return net_ads_printer_usage(argc, argv);
843 servername = argv[1];
845 servername = global_myname();
847 rc = ads_find_printer_on_server(ads, &res, argv[0], servername);
849 if (!ADS_ERR_OK(rc)) {
850 d_printf("ads_find_printer_on_server: %s\n", ads_errstr(rc));
851 ads_msgfree(ads, res);
855 if (ads_count_replies(ads, res) == 0) {
856 d_printf("Printer '%s' not found\n", argv[1]);
857 ads_msgfree(ads, res);
861 prt_dn = ads_get_dn(ads, res);
862 ads_msgfree(ads, res);
863 rc = ads_del_dn(ads, prt_dn);
864 ads_memfree(ads, prt_dn);
866 if (!ADS_ERR_OK(rc)) {
867 d_printf("ads_del_dn: %s\n", ads_errstr(rc));
874 static int net_ads_printer(int argc, const char **argv)
876 struct functable func[] = {
877 {"INFO", net_ads_printer_info},
878 {"PUBLISH", net_ads_printer_publish},
879 {"REMOVE", net_ads_printer_remove},
883 return net_run_function(argc, argv, func, net_ads_printer_usage);
887 static int net_ads_password(int argc, const char **argv)
890 const char *auth_principal = opt_user_name;
891 const char *auth_password = opt_password;
893 char *new_password = NULL;
899 if ((argc != 1) || (opt_user_name == NULL) ||
900 (opt_password == NULL) || (strchr(opt_user_name, '@') == NULL) ||
901 (strchr(argv[0], '@') == NULL)) {
902 return net_ads_usage(argc, argv);
905 use_in_memory_ccache();
906 c = strchr(auth_principal, '@');
909 /* use the realm so we can eventually change passwords for users
910 in realms other than default */
911 if (!(ads = ads_init(realm, NULL, NULL))) return -1;
913 /* we don't actually need a full connect, but it's the easy way to
914 fill in the KDC's addresss */
917 if (!ads || !ads->config.realm) {
918 d_printf("Didn't find the kerberos server!\n");
922 asprintf(&prompt, "Enter new password for %s:", argv[0]);
924 new_password = getpass(prompt);
926 ret = kerberos_set_password(ads->auth.kdc_server, auth_principal,
927 auth_password, argv[0], new_password, ads->auth.time_offset);
928 if (!ADS_ERR_OK(ret)) {
929 d_printf("Password change failed :-( ...\n");
935 d_printf("Password change for %s completed.\n", argv[0]);
943 static int net_ads_change_localhost_pass(int argc, const char **argv)
946 char *host_principal;
951 if (!secrets_init()) {
952 DEBUG(1,("Failed to initialise secrets database\n"));
956 asprintf(&user_name, "%s$", global_myname());
957 opt_user_name = user_name;
959 opt_password = secrets_fetch_machine_password();
961 use_in_memory_ccache();
963 if (!(ads = ads_startup())) {
967 hostname = strdup(global_myname());
969 asprintf(&host_principal, "%s@%s", hostname, ads->config.realm);
971 d_printf("Changing password for principal: HOST/%s\n", host_principal);
973 ret = ads_change_trust_account_password(ads, host_principal);
975 if (!ADS_ERR_OK(ret)) {
976 d_printf("Password change failed :-( ...\n");
978 SAFE_FREE(host_principal);
982 d_printf("Password change for principal HOST/%s succeeded.\n", host_principal);
984 SAFE_FREE(host_principal);
990 help for net ads search
992 static int net_ads_search_usage(int argc, const char **argv)
995 "\nnet ads search <expression> <attributes...>\n"\
996 "\nperform a raw LDAP search on a ADS server and dump the results\n"\
997 "The expression is a standard LDAP search expression, and the\n"\
998 "attributes are a list of LDAP fields to show in the results\n\n"\
999 "Example: net ads search '(objectCategory=group)' sAMAccountName\n\n"
1001 net_common_flags_usage(argc, argv);
1007 general ADS search function. Useful in diagnosing problems in ADS
1009 static int net_ads_search(int argc, const char **argv)
1018 return net_ads_search_usage(argc, argv);
1021 if (!(ads = ads_startup())) {
1028 rc = ads_do_search_all(ads, ads->config.bind_path,
1031 if (!ADS_ERR_OK(rc)) {
1032 d_printf("search failed: %s\n", ads_errstr(rc));
1036 d_printf("Got %d replies\n\n", ads_count_replies(ads, res));
1038 /* dump the results */
1041 ads_msgfree(ads, res);
1049 help for net ads search
1051 static int net_ads_dn_usage(int argc, const char **argv)
1054 "\nnet ads dn <dn> <attributes...>\n"\
1055 "\nperform a raw LDAP search on a ADS server and dump the results\n"\
1056 "The DN standard LDAP DN, and the attributes are a list of LDAP fields \n"\
1057 "to show in the results\n\n"\
1058 "Example: net ads dn 'CN=administrator,CN=Users,DC=my,DC=domain' sAMAccountName\n\n"
1060 net_common_flags_usage(argc, argv);
1066 general ADS search function. Useful in diagnosing problems in ADS
1068 static int net_ads_dn(int argc, const char **argv)
1077 return net_ads_dn_usage(argc, argv);
1080 if (!(ads = ads_startup())) {
1087 rc = ads_do_search_all(ads, dn,
1089 "(objectclass=*)", attrs, &res);
1090 if (!ADS_ERR_OK(rc)) {
1091 d_printf("search failed: %s\n", ads_errstr(rc));
1095 d_printf("Got %d replies\n\n", ads_count_replies(ads, res));
1097 /* dump the results */
1100 ads_msgfree(ads, res);
1107 int net_ads_help(int argc, const char **argv)
1109 struct functable func[] = {
1110 {"USER", net_ads_user_usage},
1111 {"GROUP", net_ads_group_usage},
1112 {"PRINTER", net_ads_printer_usage},
1113 {"SEARCH", net_ads_search_usage},
1115 {"INFO", net_ads_info},
1116 {"JOIN", net_ads_join},
1117 {"LEAVE", net_ads_leave},
1118 {"STATUS", net_ads_status},
1119 {"PASSWORD", net_ads_password},
1120 {"CHOSTPASS", net_ads_change_localhost_pass},
1125 return net_run_function(argc, argv, func, net_ads_usage);
1128 int net_ads(int argc, const char **argv)
1130 struct functable func[] = {
1131 {"INFO", net_ads_info},
1132 {"JOIN", net_ads_join},
1133 {"TESTJOIN", net_ads_testjoin},
1134 {"LEAVE", net_ads_leave},
1135 {"STATUS", net_ads_status},
1136 {"USER", net_ads_user},
1137 {"GROUP", net_ads_group},
1138 {"PASSWORD", net_ads_password},
1139 {"CHOSTPASS", net_ads_change_localhost_pass},
1140 {"PRINTER", net_ads_printer},
1141 {"SEARCH", net_ads_search},
1143 {"WORKGROUP", net_ads_workgroup},
1144 {"LOOKUP", net_ads_lookup},
1145 {"HELP", net_ads_help},
1149 return net_run_function(argc, argv, func, net_ads_usage);
1154 static int net_ads_noads(void)
1156 d_printf("ADS support not compiled in\n");
1160 int net_ads_usage(int argc, const char **argv)
1162 return net_ads_noads();
1165 int net_ads_help(int argc, const char **argv)
1167 return net_ads_noads();
1170 int net_ads_join(int argc, const char **argv)
1172 return net_ads_noads();
1175 int net_ads_user(int argc, const char **argv)
1177 return net_ads_noads();
1180 int net_ads_group(int argc, const char **argv)
1182 return net_ads_noads();
1185 /* this one shouldn't display a message */
1186 int net_ads_check(void)
1191 int net_ads(int argc, const char **argv)
1193 return net_ads_usage(argc, argv);