2 Unix SMB/CIFS implementation.
4 Winbind status program.
6 Copyright (C) Tim Potter 2000-2003
7 Copyright (C) Andrew Bartlett 2002
9 This program is free software; you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation; either version 2 of the License, or
12 (at your option) any later version.
14 This program is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
19 You should have received a copy of the GNU General Public License
20 along with this program; if not, write to the Free Software
21 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
29 #define DBGC_CLASS DBGC_WINBIND
31 extern int winbindd_fd;
33 static char winbind_separator(void)
35 struct winbindd_response response;
42 ZERO_STRUCT(response);
44 /* Send off request */
46 if (winbindd_request_response(WINBINDD_INFO, NULL, &response) !=
48 d_printf("could not obtain winbind separator!\n");
49 /* HACK: (this module should not call lp_ funtions) */
50 return *lp_winbind_separator();
53 sep = response.data.info.winbind_separator;
57 d_printf("winbind separator was NULL!\n");
58 /* HACK: (this module should not call lp_ funtions) */
59 sep = *lp_winbind_separator();
65 static const char *get_winbind_domain(void)
67 struct winbindd_response response;
68 static fstring winbind_domain;
70 ZERO_STRUCT(response);
72 /* Send off request */
74 if (winbindd_request_response(WINBINDD_DOMAIN_NAME, NULL, &response) !=
76 d_printf("could not obtain winbind domain name!\n");
78 /* HACK: (this module should not call lp_ funtions) */
79 return lp_workgroup();
82 fstrcpy(winbind_domain, response.data.domain_name);
84 return winbind_domain;
88 /* Copy of parse_domain_user from winbindd_util.c. Parse a string of the
89 form DOMAIN/user into a domain and a user */
91 static BOOL parse_wbinfo_domain_user(const char *domuser, fstring domain,
95 char *p = strchr(domuser,winbind_separator());
98 fstrcpy(user, domuser);
99 fstrcpy(domain, get_winbind_domain());
104 fstrcpy(domain, domuser);
105 domain[PTR_DIFF(p, domuser)] = 0;
111 /* List groups a user is a member of */
113 static BOOL wbinfo_get_usergroups(char *user)
115 struct winbindd_request request;
116 struct winbindd_response response;
120 ZERO_STRUCT(response);
124 fstrcpy(request.data.username, user);
126 result = winbindd_request_response(WINBINDD_GETGROUPS, &request, &response);
128 if (result != NSS_STATUS_SUCCESS)
131 for (i = 0; i < response.data.num_entries; i++)
132 d_printf("%d\n", (int)((gid_t *)response.extra_data)[i]);
134 SAFE_FREE(response.extra_data);
140 /* List group SIDs a user SID is a member of */
141 static BOOL wbinfo_get_usersids(char *user_sid)
143 struct winbindd_request request;
144 struct winbindd_response response;
149 ZERO_STRUCT(response);
152 fstrcpy(request.data.sid, user_sid);
154 result = winbindd_request_response(WINBINDD_GETUSERSIDS, &request, &response);
156 if (result != NSS_STATUS_SUCCESS)
159 s = response.extra_data;
160 for (i = 0; i < response.data.num_entries; i++) {
165 SAFE_FREE(response.extra_data);
170 static BOOL wbinfo_get_userdomgroups(const char *user_sid)
172 struct winbindd_request request;
173 struct winbindd_response response;
176 ZERO_STRUCT(response);
179 fstrcpy(request.data.sid, user_sid);
181 result = winbindd_request_response(WINBINDD_GETUSERDOMGROUPS, &request,
184 if (result != NSS_STATUS_SUCCESS)
187 if (response.data.num_entries != 0)
188 printf("%s", (char *)response.extra_data);
190 SAFE_FREE(response.extra_data);
195 /* Convert NetBIOS name to IP */
197 static BOOL wbinfo_wins_byname(char *name)
199 struct winbindd_request request;
200 struct winbindd_response response;
202 ZERO_STRUCT(request);
203 ZERO_STRUCT(response);
207 fstrcpy(request.data.winsreq, name);
209 if (winbindd_request_response(WINBINDD_WINS_BYNAME, &request, &response) !=
210 NSS_STATUS_SUCCESS) {
214 /* Display response */
216 printf("%s\n", response.data.winsresp);
221 /* Convert IP to NetBIOS name */
223 static BOOL wbinfo_wins_byip(char *ip)
225 struct winbindd_request request;
226 struct winbindd_response response;
228 ZERO_STRUCT(request);
229 ZERO_STRUCT(response);
233 fstrcpy(request.data.winsreq, ip);
235 if (winbindd_request_response(WINBINDD_WINS_BYIP, &request, &response) !=
236 NSS_STATUS_SUCCESS) {
240 /* Display response */
242 printf("%s\n", response.data.winsresp);
247 /* List trusted domains */
249 static BOOL wbinfo_list_domains(void)
251 struct winbindd_response response;
253 ZERO_STRUCT(response);
257 if (winbindd_request_response(WINBINDD_LIST_TRUSTDOM, NULL, &response) !=
261 /* Display response */
263 if (response.extra_data) {
264 const char *extra_data = (char *)response.extra_data;
268 while(next_token(&extra_data, name, "\n", sizeof(fstring))) {
269 p = strchr(name, '\\');
271 d_printf("Got invalid response: %s\n",
276 d_printf("%s\n", name);
279 SAFE_FREE(response.extra_data);
286 /* show sequence numbers */
287 static BOOL wbinfo_show_sequence(const char *domain)
289 struct winbindd_request request;
290 struct winbindd_response response;
292 ZERO_STRUCT(response);
293 ZERO_STRUCT(request);
296 fstrcpy( request.domain_name, domain );
300 if (winbindd_request_response(WINBINDD_SHOW_SEQUENCE, &request, &response) !=
304 /* Display response */
306 if (response.extra_data) {
307 char *extra_data = (char *)response.extra_data;
308 d_printf("%s", extra_data);
309 SAFE_FREE(response.extra_data);
315 /* Show domain info */
317 static BOOL wbinfo_domain_info(const char *domain_name)
319 struct winbindd_request request;
320 struct winbindd_response response;
322 ZERO_STRUCT(request);
323 ZERO_STRUCT(response);
325 fstrcpy(request.domain_name, domain_name);
329 if (winbindd_request_response(WINBINDD_DOMAIN_INFO, &request, &response) !=
333 /* Display response */
335 d_printf("Name : %s\n", response.data.domain_info.name);
336 d_printf("Alt_Name : %s\n", response.data.domain_info.alt_name);
338 d_printf("SID : %s\n", response.data.domain_info.sid);
340 d_printf("Active Directory : %s\n",
341 response.data.domain_info.active_directory ? "Yes" : "No");
342 d_printf("Native : %s\n",
343 response.data.domain_info.native_mode ? "Yes" : "No");
345 d_printf("Primary : %s\n",
346 response.data.domain_info.primary ? "Yes" : "No");
348 d_printf("Sequence : %d\n", response.data.domain_info.sequence_number);
353 /* Get a foreign DC's name */
354 static BOOL wbinfo_getdcname(const char *domain_name)
356 struct winbindd_request request;
357 struct winbindd_response response;
359 ZERO_STRUCT(request);
360 ZERO_STRUCT(response);
362 fstrcpy(request.domain_name, domain_name);
366 if (winbindd_request_response(WINBINDD_GETDCNAME, &request, &response) !=
367 NSS_STATUS_SUCCESS) {
368 d_printf("Could not get dc name for %s\n", domain_name);
372 /* Display response */
374 d_printf("%s\n", response.data.dc_name);
379 /* Check trust account password */
381 static BOOL wbinfo_check_secret(void)
383 struct winbindd_response response;
386 ZERO_STRUCT(response);
388 result = winbindd_request_response(WINBINDD_CHECK_MACHACC, NULL, &response);
390 d_printf("checking the trust secret via RPC calls %s\n",
391 (result == NSS_STATUS_SUCCESS) ? "succeeded" : "failed");
393 if (result != NSS_STATUS_SUCCESS)
394 d_printf("error code was %s (0x%x)\n",
395 response.data.auth.nt_status_string,
396 response.data.auth.nt_status);
398 return result == NSS_STATUS_SUCCESS;
401 /* Convert uid to sid */
403 static BOOL wbinfo_uid_to_sid(uid_t uid)
405 struct winbindd_request request;
406 struct winbindd_response response;
408 ZERO_STRUCT(request);
409 ZERO_STRUCT(response);
413 request.data.uid = uid;
415 if (winbindd_request_response(WINBINDD_UID_TO_SID, &request, &response) !=
419 /* Display response */
421 d_printf("%s\n", response.data.sid.sid);
426 /* Convert gid to sid */
428 static BOOL wbinfo_gid_to_sid(gid_t gid)
430 struct winbindd_request request;
431 struct winbindd_response response;
433 ZERO_STRUCT(request);
434 ZERO_STRUCT(response);
438 request.data.gid = gid;
440 if (winbindd_request_response(WINBINDD_GID_TO_SID, &request, &response) !=
444 /* Display response */
446 d_printf("%s\n", response.data.sid.sid);
451 /* Convert sid to uid */
453 static BOOL wbinfo_sid_to_uid(char *sid)
455 struct winbindd_request request;
456 struct winbindd_response response;
458 ZERO_STRUCT(request);
459 ZERO_STRUCT(response);
463 fstrcpy(request.data.sid, sid);
465 if (winbindd_request_response(WINBINDD_SID_TO_UID, &request, &response) !=
469 /* Display response */
471 d_printf("%d\n", (int)response.data.uid);
476 static BOOL wbinfo_sid_to_gid(char *sid)
478 struct winbindd_request request;
479 struct winbindd_response response;
481 ZERO_STRUCT(request);
482 ZERO_STRUCT(response);
486 fstrcpy(request.data.sid, sid);
488 if (winbindd_request_response(WINBINDD_SID_TO_GID, &request, &response) !=
492 /* Display response */
494 d_printf("%d\n", (int)response.data.gid);
499 static BOOL wbinfo_allocate_rid(void)
503 if (!winbind_allocate_rid(&rid))
506 d_printf("New rid: %d\n", rid);
511 /* Convert sid to string */
513 static BOOL wbinfo_lookupsid(char *sid)
515 struct winbindd_request request;
516 struct winbindd_response response;
518 ZERO_STRUCT(request);
519 ZERO_STRUCT(response);
521 /* Send off request */
523 fstrcpy(request.data.sid, sid);
525 if (winbindd_request_response(WINBINDD_LOOKUPSID, &request, &response) !=
529 /* Display response */
531 d_printf("%s%c%s %d\n", response.data.name.dom_name,
532 winbind_separator(), response.data.name.name,
533 response.data.name.type);
538 /* Convert string to sid */
540 static BOOL wbinfo_lookupname(char *name)
542 struct winbindd_request request;
543 struct winbindd_response response;
545 /* Send off request */
547 ZERO_STRUCT(request);
548 ZERO_STRUCT(response);
550 parse_wbinfo_domain_user(name, request.data.name.dom_name,
551 request.data.name.name);
553 if (winbindd_request_response(WINBINDD_LOOKUPNAME, &request, &response) !=
557 /* Display response */
559 d_printf("%s %s (%d)\n", response.data.sid.sid, sid_type_lookup(response.data.sid.type), response.data.sid.type);
564 /* Authenticate a user with a plaintext password */
566 static BOOL wbinfo_auth(char *username)
568 struct winbindd_request request;
569 struct winbindd_response response;
573 /* Send off request */
575 ZERO_STRUCT(request);
576 ZERO_STRUCT(response);
578 p = strchr(username, '%');
582 fstrcpy(request.data.auth.user, username);
583 fstrcpy(request.data.auth.pass, p + 1);
586 fstrcpy(request.data.auth.user, username);
588 result = winbindd_request_response(WINBINDD_PAM_AUTH, &request, &response);
590 /* Display response */
592 d_printf("plaintext password authentication %s\n",
593 (result == NSS_STATUS_SUCCESS) ? "succeeded" : "failed");
595 if (response.data.auth.nt_status)
596 d_printf("error code was %s (0x%x)\nerror messsage was: %s\n",
597 response.data.auth.nt_status_string,
598 response.data.auth.nt_status,
599 response.data.auth.error_string);
601 return result == NSS_STATUS_SUCCESS;
604 /* Authenticate a user with a challenge/response */
606 static BOOL wbinfo_auth_crap(char *username)
608 struct winbindd_request request;
609 struct winbindd_response response;
616 /* Send off request */
618 ZERO_STRUCT(request);
619 ZERO_STRUCT(response);
621 p = strchr(username, '%');
625 fstrcpy(pass, p + 1);
628 parse_wbinfo_domain_user(username, name_domain, name_user);
630 fstrcpy(request.data.auth_crap.user, name_user);
632 fstrcpy(request.data.auth_crap.domain,
635 generate_random_buffer(request.data.auth_crap.chal, 8);
637 if (lp_client_ntlmv2_auth()) {
638 DATA_BLOB server_chal;
639 DATA_BLOB names_blob;
641 DATA_BLOB lm_response;
642 DATA_BLOB nt_response;
644 server_chal = data_blob(request.data.auth_crap.chal, 8);
646 /* Pretend this is a login to 'us', for blob purposes */
647 names_blob = NTLMv2_generate_names_blob(global_myname(), lp_workgroup());
649 if (!SMBNTLMv2encrypt(name_user, name_domain, pass, &server_chal,
651 &lm_response, &nt_response, NULL)) {
652 data_blob_free(&names_blob);
653 data_blob_free(&server_chal);
656 data_blob_free(&names_blob);
657 data_blob_free(&server_chal);
659 memcpy(request.data.auth_crap.nt_resp, nt_response.data,
660 MIN(nt_response.length,
661 sizeof(request.data.auth_crap.nt_resp)));
662 request.data.auth_crap.nt_resp_len = nt_response.length;
664 memcpy(request.data.auth_crap.lm_resp, lm_response.data,
665 MIN(lm_response.length,
666 sizeof(request.data.auth_crap.lm_resp)));
667 request.data.auth_crap.lm_resp_len = lm_response.length;
669 data_blob_free(&nt_response);
670 data_blob_free(&lm_response);
673 if (lp_client_lanman_auth()
674 && SMBencrypt(pass, request.data.auth_crap.chal,
675 (uchar *)request.data.auth_crap.lm_resp)) {
676 request.data.auth_crap.lm_resp_len = 24;
678 request.data.auth_crap.lm_resp_len = 0;
680 SMBNTencrypt(pass, request.data.auth_crap.chal,
681 (uchar *)request.data.auth_crap.nt_resp);
683 request.data.auth_crap.nt_resp_len = 24;
686 result = winbindd_request_response(WINBINDD_PAM_AUTH_CRAP, &request, &response);
688 /* Display response */
690 d_printf("challenge/response password authentication %s\n",
691 (result == NSS_STATUS_SUCCESS) ? "succeeded" : "failed");
693 if (response.data.auth.nt_status)
694 d_printf("error code was %s (0x%x)\nerror messsage was: %s\n",
695 response.data.auth.nt_status_string,
696 response.data.auth.nt_status,
697 response.data.auth.error_string);
699 return result == NSS_STATUS_SUCCESS;
702 /* Authenticate a user with a plaintext password and set a token */
704 static BOOL wbinfo_klog(char *username)
706 struct winbindd_request request;
707 struct winbindd_response response;
711 /* Send off request */
713 ZERO_STRUCT(request);
714 ZERO_STRUCT(response);
716 p = strchr(username, '%');
720 fstrcpy(request.data.auth.user, username);
721 fstrcpy(request.data.auth.pass, p + 1);
724 fstrcpy(request.data.auth.user, username);
725 fstrcpy(request.data.auth.pass, getpass("Password: "));
728 request.flags |= WBFLAG_PAM_AFS_TOKEN;
730 result = winbindd_request_response(WINBINDD_PAM_AUTH, &request, &response);
732 /* Display response */
734 d_printf("plaintext password authentication %s\n",
735 (result == NSS_STATUS_SUCCESS) ? "succeeded" : "failed");
737 if (response.data.auth.nt_status)
738 d_printf("error code was %s (0x%x)\nerror messsage was: %s\n",
739 response.data.auth.nt_status_string,
740 response.data.auth.nt_status,
741 response.data.auth.error_string);
743 if (result != NSS_STATUS_SUCCESS)
746 if (response.extra_data == NULL) {
747 d_printf("Did not get token data\n");
751 if (!afs_settoken_str((char *)response.extra_data)) {
752 d_printf("Could not set token\n");
756 d_printf("Successfully created AFS token\n");
760 /* Print domain users */
762 static BOOL print_domain_users(const char *domain)
764 struct winbindd_request request;
765 struct winbindd_response response;
766 const char *extra_data;
769 /* Send request to winbind daemon */
771 ZERO_STRUCT(request);
772 ZERO_STRUCT(response);
775 /* '.' is the special sign for our own domwin */
776 if ( strequal(domain, ".") )
777 fstrcpy( request.domain_name, lp_workgroup() );
779 fstrcpy( request.domain_name, domain );
782 if (winbindd_request_response(WINBINDD_LIST_USERS, &request, &response) !=
786 /* Look through extra data */
788 if (!response.extra_data)
791 extra_data = (const char *)response.extra_data;
793 while(next_token(&extra_data, name, ",", sizeof(fstring)))
794 d_printf("%s\n", name);
796 SAFE_FREE(response.extra_data);
801 /* Print domain groups */
803 static BOOL print_domain_groups(const char *domain)
805 struct winbindd_request request;
806 struct winbindd_response response;
807 const char *extra_data;
810 ZERO_STRUCT(request);
811 ZERO_STRUCT(response);
814 if ( strequal(domain, ".") )
815 fstrcpy( request.domain_name, lp_workgroup() );
817 fstrcpy( request.domain_name, domain );
820 if (winbindd_request_response(WINBINDD_LIST_GROUPS, &request, &response) !=
824 /* Look through extra data */
826 if (!response.extra_data)
829 extra_data = (const char *)response.extra_data;
831 while(next_token(&extra_data, name, ",", sizeof(fstring)))
832 d_printf("%s\n", name);
834 SAFE_FREE(response.extra_data);
839 /* Set the authorised user for winbindd access in secrets.tdb */
841 static BOOL wbinfo_set_auth_user(char *username)
843 const char *password;
845 fstring user, domain;
847 /* Separate into user and password */
849 parse_wbinfo_domain_user(username, domain, user);
851 p = strchr(user, '%');
857 char *thepass = getpass("Password: ");
864 /* Store or remove DOMAIN\username%password in secrets.tdb */
870 if (!secrets_store(SECRETS_AUTH_USER, user,
872 d_fprintf(stderr, "error storing username\n");
876 /* We always have a domain name added by the
877 parse_wbinfo_domain_user() function. */
879 if (!secrets_store(SECRETS_AUTH_DOMAIN, domain,
880 strlen(domain) + 1)) {
881 d_fprintf(stderr, "error storing domain name\n");
886 secrets_delete(SECRETS_AUTH_USER);
887 secrets_delete(SECRETS_AUTH_DOMAIN);
892 if (!secrets_store(SECRETS_AUTH_PASSWORD, password,
893 strlen(password) + 1)) {
894 d_fprintf(stderr, "error storing password\n");
899 secrets_delete(SECRETS_AUTH_PASSWORD);
904 static void wbinfo_get_auth_user(void)
906 char *user, *domain, *password;
908 /* Lift data from secrets file */
910 secrets_fetch_ipc_userpass(&user, &domain, &password);
912 if ((!user || !*user) && (!domain || !*domain ) && (!password || !*password)){
917 d_printf("No authorised user configured\n");
921 /* Pretty print authorised user info */
923 d_printf("%s%s%s%s%s\n", domain ? domain : "", domain ? lp_winbind_separator(): "",
924 user, password ? "%" : "", password ? password : "");
931 static BOOL wbinfo_ping(void)
935 result = winbindd_request_response(WINBINDD_PING, NULL, NULL);
937 /* Display response */
939 d_printf("Ping to winbindd %s on fd %d\n",
940 (result == NSS_STATUS_SUCCESS) ? "succeeded" : "failed", winbindd_fd);
942 return result == NSS_STATUS_SUCCESS;
948 OPT_SET_AUTH_USER = 1000,
957 int main(int argc, char **argv)
962 static char *string_arg;
963 static char *opt_domain_name;
967 struct poptOption long_options[] = {
970 /* longName, shortName, argInfo, argPtr, value, descrip,
973 { "domain-users", 'u', POPT_ARG_NONE, 0, 'u', "Lists all domain users", "domain"},
974 { "domain-groups", 'g', POPT_ARG_NONE, 0, 'g', "Lists all domain groups", "domain" },
975 { "WINS-by-name", 'N', POPT_ARG_STRING, &string_arg, 'N', "Converts NetBIOS name to IP", "NETBIOS-NAME" },
976 { "WINS-by-ip", 'I', POPT_ARG_STRING, &string_arg, 'I', "Converts IP address to NetBIOS name", "IP" },
977 { "name-to-sid", 'n', POPT_ARG_STRING, &string_arg, 'n', "Converts name to sid", "NAME" },
978 { "sid-to-name", 's', POPT_ARG_STRING, &string_arg, 's', "Converts sid to name", "SID" },
979 { "uid-to-sid", 'U', POPT_ARG_INT, &int_arg, 'U', "Converts uid to sid" , "UID" },
980 { "gid-to-sid", 'G', POPT_ARG_INT, &int_arg, 'G', "Converts gid to sid", "GID" },
981 { "sid-to-uid", 'S', POPT_ARG_STRING, &string_arg, 'S', "Converts sid to uid", "SID" },
982 { "sid-to-gid", 'Y', POPT_ARG_STRING, &string_arg, 'Y', "Converts sid to gid", "SID" },
983 { "allocate-rid", 'A', POPT_ARG_NONE, 0, 'A', "Get a new RID out of idmap" },
984 { "check-secret", 't', POPT_ARG_NONE, 0, 't', "Check shared secret" },
985 { "trusted-domains", 'm', POPT_ARG_NONE, 0, 'm', "List trusted domains" },
986 { "sequence", 0, POPT_ARG_NONE, 0, OPT_SEQUENCE, "Show sequence numbers of all domains" },
987 { "domain-info", 'D', POPT_ARG_STRING, &string_arg, 'D', "Show most of the info we have about the domain" },
988 { "user-groups", 'r', POPT_ARG_STRING, &string_arg, 'r', "Get user groups", "USER" },
989 { "user-domgroups", 0, POPT_ARG_STRING, &string_arg,
990 OPT_USERDOMGROUPS, "Get user domain groups", "SID" },
991 { "user-sids", 0, POPT_ARG_STRING, &string_arg, OPT_USERSIDS, "Get user group sids for user SID", "SID" },
992 { "authenticate", 'a', POPT_ARG_STRING, &string_arg, 'a', "authenticate user", "user%password" },
993 { "set-auth-user", 0, POPT_ARG_STRING, &string_arg, OPT_SET_AUTH_USER, "Store user and password used by winbindd (root only)", "user%password" },
994 { "getdcname", 0, POPT_ARG_STRING, &string_arg, OPT_GETDCNAME,
995 "Get a DC name for a foreign domain", "domainname" },
996 { "get-auth-user", 0, POPT_ARG_NONE, NULL, OPT_GET_AUTH_USER, "Retrieve user and password used by winbindd (root only)", NULL },
997 { "ping", 'p', POPT_ARG_NONE, 0, 'p', "Ping winbindd to see if it is alive" },
998 { "domain", 0, POPT_ARG_STRING, &opt_domain_name, OPT_DOMAIN_NAME, "Define to the domain to restrict operation", "domain" },
999 #ifdef WITH_FAKE_KASERVER
1000 { "klog", 'k', POPT_ARG_STRING, &string_arg, 'k', "set an AFS token from winbind", "user%password" },
1006 /* Samba client initialisation */
1008 if (!lp_load(dyn_CONFIGFILE, True, False, False)) {
1009 d_fprintf(stderr, "wbinfo: error opening config file %s. Error was %s\n",
1010 dyn_CONFIGFILE, strerror(errno));
1021 pc = poptGetContext("wbinfo", argc, (const char **)argv, long_options, 0);
1023 /* Parse command line options */
1026 poptPrintHelp(pc, stderr, 0);
1030 while((opt = poptGetNextOpt(pc)) != -1) {
1031 /* get the generic configuration parameters like --domain */
1034 poptFreeContext(pc);
1036 pc = poptGetContext(NULL, argc, (const char **)argv, long_options,
1037 POPT_CONTEXT_KEEP_FIRST);
1039 while((opt = poptGetNextOpt(pc)) != -1) {
1042 if (!print_domain_users(opt_domain_name)) {
1043 d_printf("Error looking up domain users\n");
1048 if (!print_domain_groups(opt_domain_name)) {
1049 d_printf("Error looking up domain groups\n");
1054 if (!wbinfo_lookupsid(string_arg)) {
1055 d_printf("Could not lookup sid %s\n", string_arg);
1060 if (!wbinfo_lookupname(string_arg)) {
1061 d_printf("Could not lookup name %s\n", string_arg);
1066 if (!wbinfo_wins_byname(string_arg)) {
1067 d_printf("Could not lookup WINS by name %s\n", string_arg);
1072 if (!wbinfo_wins_byip(string_arg)) {
1073 d_printf("Could not lookup WINS by IP %s\n", string_arg);
1078 if (!wbinfo_uid_to_sid(int_arg)) {
1079 d_printf("Could not convert uid %d to sid\n", int_arg);
1084 if (!wbinfo_gid_to_sid(int_arg)) {
1085 d_printf("Could not convert gid %d to sid\n",
1091 if (!wbinfo_sid_to_uid(string_arg)) {
1092 d_printf("Could not convert sid %s to uid\n",
1098 if (!wbinfo_sid_to_gid(string_arg)) {
1099 d_printf("Could not convert sid %s to gid\n",
1105 if (!wbinfo_allocate_rid()) {
1106 d_printf("Could not allocate a RID\n");
1111 if (!wbinfo_check_secret()) {
1112 d_printf("Could not check secret\n");
1117 if (!wbinfo_list_domains()) {
1118 d_printf("Could not list trusted domains\n");
1123 if (!wbinfo_show_sequence(opt_domain_name)) {
1124 d_printf("Could not show sequence numbers\n");
1129 if (!wbinfo_domain_info(string_arg)) {
1130 d_printf("Could not get domain info\n");
1135 if (!wbinfo_get_usergroups(string_arg)) {
1136 d_printf("Could not get groups for user %s\n",
1142 if (!wbinfo_get_usersids(string_arg)) {
1143 d_printf("Could not get group SIDs for user SID %s\n",
1148 case OPT_USERDOMGROUPS:
1149 if (!wbinfo_get_userdomgroups(string_arg)) {
1150 d_printf("Could not get user's domain groups "
1151 "for user SID %s\n", string_arg);
1156 BOOL got_error = False;
1158 if (!wbinfo_auth(string_arg)) {
1159 d_printf("Could not authenticate user %s with "
1160 "plaintext password\n", string_arg);
1164 if (!wbinfo_auth_crap(string_arg)) {
1165 d_printf("Could not authenticate user %s with "
1166 "challenge/response\n", string_arg);
1175 if (!wbinfo_klog(string_arg)) {
1176 d_printf("Could not klog user\n");
1181 if (!wbinfo_ping()) {
1182 d_printf("could not ping winbindd!\n");
1186 case OPT_SET_AUTH_USER:
1187 wbinfo_set_auth_user(string_arg);
1189 case OPT_GET_AUTH_USER:
1190 wbinfo_get_auth_user();
1193 wbinfo_getdcname(string_arg);
1195 /* generic configuration options */
1196 case OPT_DOMAIN_NAME:
1199 d_fprintf(stderr, "Invalid option\n");
1200 poptPrintHelp(pc, stderr, 0);
1210 poptFreeContext(pc);