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(request);
121 ZERO_STRUCT(response);
125 fstrcpy(request.data.username, user);
127 result = winbindd_request_response(WINBINDD_GETGROUPS, &request, &response);
129 if (result != NSS_STATUS_SUCCESS)
132 for (i = 0; i < response.data.num_entries; i++)
133 d_printf("%d\n", (int)((gid_t *)response.extra_data)[i]);
135 SAFE_FREE(response.extra_data);
141 /* List group SIDs a user SID is a member of */
142 static BOOL wbinfo_get_usersids(char *user_sid)
144 struct winbindd_request request;
145 struct winbindd_response response;
150 ZERO_STRUCT(request);
151 ZERO_STRUCT(response);
154 fstrcpy(request.data.sid, user_sid);
156 result = winbindd_request_response(WINBINDD_GETUSERSIDS, &request, &response);
158 if (result != NSS_STATUS_SUCCESS)
161 s = response.extra_data;
162 for (i = 0; i < response.data.num_entries; i++) {
167 SAFE_FREE(response.extra_data);
172 static BOOL wbinfo_get_userdomgroups(const char *user_sid)
174 struct winbindd_request request;
175 struct winbindd_response response;
178 ZERO_STRUCT(request);
179 ZERO_STRUCT(response);
182 fstrcpy(request.data.sid, user_sid);
184 result = winbindd_request_response(WINBINDD_GETUSERDOMGROUPS, &request,
187 if (result != NSS_STATUS_SUCCESS)
190 if (response.data.num_entries != 0)
191 printf("%s", (char *)response.extra_data);
193 SAFE_FREE(response.extra_data);
198 /* Convert NetBIOS name to IP */
200 static BOOL wbinfo_wins_byname(char *name)
202 struct winbindd_request request;
203 struct winbindd_response response;
205 ZERO_STRUCT(request);
206 ZERO_STRUCT(response);
210 fstrcpy(request.data.winsreq, name);
212 if (winbindd_request_response(WINBINDD_WINS_BYNAME, &request, &response) !=
213 NSS_STATUS_SUCCESS) {
217 /* Display response */
219 printf("%s\n", response.data.winsresp);
224 /* Convert IP to NetBIOS name */
226 static BOOL wbinfo_wins_byip(char *ip)
228 struct winbindd_request request;
229 struct winbindd_response response;
231 ZERO_STRUCT(request);
232 ZERO_STRUCT(response);
236 fstrcpy(request.data.winsreq, ip);
238 if (winbindd_request_response(WINBINDD_WINS_BYIP, &request, &response) !=
239 NSS_STATUS_SUCCESS) {
243 /* Display response */
245 printf("%s\n", response.data.winsresp);
250 /* List trusted domains */
252 static BOOL wbinfo_list_domains(void)
254 struct winbindd_response response;
256 ZERO_STRUCT(response);
260 if (winbindd_request_response(WINBINDD_LIST_TRUSTDOM, NULL, &response) !=
264 /* Display response */
266 if (response.extra_data) {
267 const char *extra_data = (char *)response.extra_data;
271 while(next_token(&extra_data, name, "\n", sizeof(fstring))) {
272 p = strchr(name, '\\');
274 d_printf("Got invalid response: %s\n",
279 d_printf("%s\n", name);
282 SAFE_FREE(response.extra_data);
289 /* show sequence numbers */
290 static BOOL wbinfo_show_sequence(const char *domain)
292 struct winbindd_request request;
293 struct winbindd_response response;
295 ZERO_STRUCT(response);
296 ZERO_STRUCT(request);
299 fstrcpy( request.domain_name, domain );
303 if (winbindd_request_response(WINBINDD_SHOW_SEQUENCE, &request, &response) !=
307 /* Display response */
309 if (response.extra_data) {
310 char *extra_data = (char *)response.extra_data;
311 d_printf("%s", extra_data);
312 SAFE_FREE(response.extra_data);
318 /* Show domain info */
320 static BOOL wbinfo_domain_info(const char *domain_name)
322 struct winbindd_request request;
323 struct winbindd_response response;
325 ZERO_STRUCT(request);
326 ZERO_STRUCT(response);
328 fstrcpy(request.domain_name, domain_name);
332 if (winbindd_request_response(WINBINDD_DOMAIN_INFO, &request, &response) !=
336 /* Display response */
338 d_printf("Name : %s\n", response.data.domain_info.name);
339 d_printf("Alt_Name : %s\n", response.data.domain_info.alt_name);
341 d_printf("SID : %s\n", response.data.domain_info.sid);
343 d_printf("Active Directory : %s\n",
344 response.data.domain_info.active_directory ? "Yes" : "No");
345 d_printf("Native : %s\n",
346 response.data.domain_info.native_mode ? "Yes" : "No");
348 d_printf("Primary : %s\n",
349 response.data.domain_info.primary ? "Yes" : "No");
351 d_printf("Sequence : %d\n", response.data.domain_info.sequence_number);
356 /* Get a foreign DC's name */
357 static BOOL wbinfo_getdcname(const char *domain_name)
359 struct winbindd_request request;
360 struct winbindd_response response;
362 ZERO_STRUCT(request);
363 ZERO_STRUCT(response);
365 fstrcpy(request.domain_name, domain_name);
369 if (winbindd_request_response(WINBINDD_GETDCNAME, &request, &response) !=
370 NSS_STATUS_SUCCESS) {
371 d_printf("Could not get dc name for %s\n", domain_name);
375 /* Display response */
377 d_printf("%s\n", response.data.dc_name);
382 /* Check trust account password */
384 static BOOL wbinfo_check_secret(void)
386 struct winbindd_response response;
389 ZERO_STRUCT(response);
391 result = winbindd_request_response(WINBINDD_CHECK_MACHACC, NULL, &response);
393 d_printf("checking the trust secret via RPC calls %s\n",
394 (result == NSS_STATUS_SUCCESS) ? "succeeded" : "failed");
396 if (result != NSS_STATUS_SUCCESS)
397 d_printf("error code was %s (0x%x)\n",
398 response.data.auth.nt_status_string,
399 response.data.auth.nt_status);
401 return result == NSS_STATUS_SUCCESS;
404 /* Convert uid to sid */
406 static BOOL wbinfo_uid_to_sid(uid_t uid)
408 struct winbindd_request request;
409 struct winbindd_response response;
411 ZERO_STRUCT(request);
412 ZERO_STRUCT(response);
416 request.data.uid = uid;
418 if (winbindd_request_response(WINBINDD_UID_TO_SID, &request, &response) !=
422 /* Display response */
424 d_printf("%s\n", response.data.sid.sid);
429 /* Convert gid to sid */
431 static BOOL wbinfo_gid_to_sid(gid_t gid)
433 struct winbindd_request request;
434 struct winbindd_response response;
436 ZERO_STRUCT(request);
437 ZERO_STRUCT(response);
441 request.data.gid = gid;
443 if (winbindd_request_response(WINBINDD_GID_TO_SID, &request, &response) !=
447 /* Display response */
449 d_printf("%s\n", response.data.sid.sid);
454 /* Convert sid to uid */
456 static BOOL wbinfo_sid_to_uid(char *sid)
458 struct winbindd_request request;
459 struct winbindd_response response;
461 ZERO_STRUCT(request);
462 ZERO_STRUCT(response);
466 fstrcpy(request.data.sid, sid);
468 if (winbindd_request_response(WINBINDD_SID_TO_UID, &request, &response) !=
472 /* Display response */
474 d_printf("%d\n", (int)response.data.uid);
479 static BOOL wbinfo_sid_to_gid(char *sid)
481 struct winbindd_request request;
482 struct winbindd_response response;
484 ZERO_STRUCT(request);
485 ZERO_STRUCT(response);
489 fstrcpy(request.data.sid, sid);
491 if (winbindd_request_response(WINBINDD_SID_TO_GID, &request, &response) !=
495 /* Display response */
497 d_printf("%d\n", (int)response.data.gid);
502 static BOOL wbinfo_allocate_rid(void)
506 if (!winbind_allocate_rid(&rid))
509 d_printf("New rid: %d\n", rid);
514 /* Convert sid to string */
516 static BOOL wbinfo_lookupsid(char *sid)
518 struct winbindd_request request;
519 struct winbindd_response response;
521 ZERO_STRUCT(request);
522 ZERO_STRUCT(response);
524 /* Send off request */
526 fstrcpy(request.data.sid, sid);
528 if (winbindd_request_response(WINBINDD_LOOKUPSID, &request, &response) !=
532 /* Display response */
534 d_printf("%s%c%s %d\n", response.data.name.dom_name,
535 winbind_separator(), response.data.name.name,
536 response.data.name.type);
541 /* Convert string to sid */
543 static BOOL wbinfo_lookupname(char *name)
545 struct winbindd_request request;
546 struct winbindd_response response;
548 /* Send off request */
550 ZERO_STRUCT(request);
551 ZERO_STRUCT(response);
553 parse_wbinfo_domain_user(name, request.data.name.dom_name,
554 request.data.name.name);
556 if (winbindd_request_response(WINBINDD_LOOKUPNAME, &request, &response) !=
560 /* Display response */
562 d_printf("%s %s (%d)\n", response.data.sid.sid, sid_type_lookup(response.data.sid.type), response.data.sid.type);
567 /* Authenticate a user with a plaintext password */
569 static BOOL wbinfo_auth(char *username)
571 struct winbindd_request request;
572 struct winbindd_response response;
576 /* Send off request */
578 ZERO_STRUCT(request);
579 ZERO_STRUCT(response);
581 p = strchr(username, '%');
585 fstrcpy(request.data.auth.user, username);
586 fstrcpy(request.data.auth.pass, p + 1);
589 fstrcpy(request.data.auth.user, username);
591 result = winbindd_request_response(WINBINDD_PAM_AUTH, &request, &response);
593 /* Display response */
595 d_printf("plaintext password authentication %s\n",
596 (result == NSS_STATUS_SUCCESS) ? "succeeded" : "failed");
598 if (response.data.auth.nt_status)
599 d_printf("error code was %s (0x%x)\nerror messsage was: %s\n",
600 response.data.auth.nt_status_string,
601 response.data.auth.nt_status,
602 response.data.auth.error_string);
604 return result == NSS_STATUS_SUCCESS;
607 /* Authenticate a user with a challenge/response */
609 static BOOL wbinfo_auth_crap(char *username)
611 struct winbindd_request request;
612 struct winbindd_response response;
619 /* Send off request */
621 ZERO_STRUCT(request);
622 ZERO_STRUCT(response);
624 p = strchr(username, '%');
628 fstrcpy(pass, p + 1);
631 parse_wbinfo_domain_user(username, name_domain, name_user);
633 fstrcpy(request.data.auth_crap.user, name_user);
635 fstrcpy(request.data.auth_crap.domain,
638 generate_random_buffer(request.data.auth_crap.chal, 8);
640 if (lp_client_ntlmv2_auth()) {
641 DATA_BLOB server_chal;
642 DATA_BLOB names_blob;
644 DATA_BLOB lm_response;
645 DATA_BLOB nt_response;
647 server_chal = data_blob(request.data.auth_crap.chal, 8);
649 /* Pretend this is a login to 'us', for blob purposes */
650 names_blob = NTLMv2_generate_names_blob(global_myname(), lp_workgroup());
652 if (!SMBNTLMv2encrypt(name_user, name_domain, pass, &server_chal,
654 &lm_response, &nt_response, NULL)) {
655 data_blob_free(&names_blob);
656 data_blob_free(&server_chal);
659 data_blob_free(&names_blob);
660 data_blob_free(&server_chal);
662 memcpy(request.data.auth_crap.nt_resp, nt_response.data,
663 MIN(nt_response.length,
664 sizeof(request.data.auth_crap.nt_resp)));
665 request.data.auth_crap.nt_resp_len = nt_response.length;
667 memcpy(request.data.auth_crap.lm_resp, lm_response.data,
668 MIN(lm_response.length,
669 sizeof(request.data.auth_crap.lm_resp)));
670 request.data.auth_crap.lm_resp_len = lm_response.length;
672 data_blob_free(&nt_response);
673 data_blob_free(&lm_response);
676 if (lp_client_lanman_auth()
677 && SMBencrypt(pass, request.data.auth_crap.chal,
678 (uchar *)request.data.auth_crap.lm_resp)) {
679 request.data.auth_crap.lm_resp_len = 24;
681 request.data.auth_crap.lm_resp_len = 0;
683 SMBNTencrypt(pass, request.data.auth_crap.chal,
684 (uchar *)request.data.auth_crap.nt_resp);
686 request.data.auth_crap.nt_resp_len = 24;
689 result = winbindd_request_response(WINBINDD_PAM_AUTH_CRAP, &request, &response);
691 /* Display response */
693 d_printf("challenge/response password authentication %s\n",
694 (result == NSS_STATUS_SUCCESS) ? "succeeded" : "failed");
696 if (response.data.auth.nt_status)
697 d_printf("error code was %s (0x%x)\nerror messsage was: %s\n",
698 response.data.auth.nt_status_string,
699 response.data.auth.nt_status,
700 response.data.auth.error_string);
702 return result == NSS_STATUS_SUCCESS;
705 /* Authenticate a user with a plaintext password and set a token */
707 static BOOL wbinfo_klog(char *username)
709 struct winbindd_request request;
710 struct winbindd_response response;
714 /* Send off request */
716 ZERO_STRUCT(request);
717 ZERO_STRUCT(response);
719 p = strchr(username, '%');
723 fstrcpy(request.data.auth.user, username);
724 fstrcpy(request.data.auth.pass, p + 1);
727 fstrcpy(request.data.auth.user, username);
728 fstrcpy(request.data.auth.pass, getpass("Password: "));
731 request.flags |= WBFLAG_PAM_AFS_TOKEN;
733 result = winbindd_request_response(WINBINDD_PAM_AUTH, &request, &response);
735 /* Display response */
737 d_printf("plaintext password authentication %s\n",
738 (result == NSS_STATUS_SUCCESS) ? "succeeded" : "failed");
740 if (response.data.auth.nt_status)
741 d_printf("error code was %s (0x%x)\nerror messsage was: %s\n",
742 response.data.auth.nt_status_string,
743 response.data.auth.nt_status,
744 response.data.auth.error_string);
746 if (result != NSS_STATUS_SUCCESS)
749 if (response.extra_data == NULL) {
750 d_printf("Did not get token data\n");
754 if (!afs_settoken_str((char *)response.extra_data)) {
755 d_printf("Could not set token\n");
759 d_printf("Successfully created AFS token\n");
763 /* Print domain users */
765 static BOOL print_domain_users(const char *domain)
767 struct winbindd_request request;
768 struct winbindd_response response;
769 const char *extra_data;
772 /* Send request to winbind daemon */
774 ZERO_STRUCT(request);
775 ZERO_STRUCT(response);
778 /* '.' is the special sign for our own domwin */
779 if ( strequal(domain, ".") )
780 fstrcpy( request.domain_name, lp_workgroup() );
782 fstrcpy( request.domain_name, domain );
785 if (winbindd_request_response(WINBINDD_LIST_USERS, &request, &response) !=
789 /* Look through extra data */
791 if (!response.extra_data)
794 extra_data = (const char *)response.extra_data;
796 while(next_token(&extra_data, name, ",", sizeof(fstring)))
797 d_printf("%s\n", name);
799 SAFE_FREE(response.extra_data);
804 /* Print domain groups */
806 static BOOL print_domain_groups(const char *domain)
808 struct winbindd_request request;
809 struct winbindd_response response;
810 const char *extra_data;
813 ZERO_STRUCT(request);
814 ZERO_STRUCT(response);
817 if ( strequal(domain, ".") )
818 fstrcpy( request.domain_name, lp_workgroup() );
820 fstrcpy( request.domain_name, domain );
823 if (winbindd_request_response(WINBINDD_LIST_GROUPS, &request, &response) !=
827 /* Look through extra data */
829 if (!response.extra_data)
832 extra_data = (const char *)response.extra_data;
834 while(next_token(&extra_data, name, ",", sizeof(fstring)))
835 d_printf("%s\n", name);
837 SAFE_FREE(response.extra_data);
842 /* Set the authorised user for winbindd access in secrets.tdb */
844 static BOOL wbinfo_set_auth_user(char *username)
846 const char *password;
848 fstring user, domain;
850 /* Separate into user and password */
852 parse_wbinfo_domain_user(username, domain, user);
854 p = strchr(user, '%');
860 char *thepass = getpass("Password: ");
867 /* Store or remove DOMAIN\username%password in secrets.tdb */
873 if (!secrets_store(SECRETS_AUTH_USER, user,
875 d_fprintf(stderr, "error storing username\n");
879 /* We always have a domain name added by the
880 parse_wbinfo_domain_user() function. */
882 if (!secrets_store(SECRETS_AUTH_DOMAIN, domain,
883 strlen(domain) + 1)) {
884 d_fprintf(stderr, "error storing domain name\n");
889 secrets_delete(SECRETS_AUTH_USER);
890 secrets_delete(SECRETS_AUTH_DOMAIN);
895 if (!secrets_store(SECRETS_AUTH_PASSWORD, password,
896 strlen(password) + 1)) {
897 d_fprintf(stderr, "error storing password\n");
902 secrets_delete(SECRETS_AUTH_PASSWORD);
907 static void wbinfo_get_auth_user(void)
909 char *user, *domain, *password;
911 /* Lift data from secrets file */
913 secrets_fetch_ipc_userpass(&user, &domain, &password);
915 if ((!user || !*user) && (!domain || !*domain ) && (!password || !*password)){
920 d_printf("No authorised user configured\n");
924 /* Pretty print authorised user info */
926 d_printf("%s%s%s%s%s\n", domain ? domain : "", domain ? lp_winbind_separator(): "",
927 user, password ? "%" : "", password ? password : "");
934 static BOOL wbinfo_ping(void)
938 result = winbindd_request_response(WINBINDD_PING, NULL, NULL);
940 /* Display response */
942 d_printf("Ping to winbindd %s on fd %d\n",
943 (result == NSS_STATUS_SUCCESS) ? "succeeded" : "failed", winbindd_fd);
945 return result == NSS_STATUS_SUCCESS;
951 OPT_SET_AUTH_USER = 1000,
960 int main(int argc, char **argv)
965 static char *string_arg;
966 static char *opt_domain_name;
970 struct poptOption long_options[] = {
973 /* longName, shortName, argInfo, argPtr, value, descrip,
976 { "domain-users", 'u', POPT_ARG_NONE, 0, 'u', "Lists all domain users", "domain"},
977 { "domain-groups", 'g', POPT_ARG_NONE, 0, 'g', "Lists all domain groups", "domain" },
978 { "WINS-by-name", 'N', POPT_ARG_STRING, &string_arg, 'N', "Converts NetBIOS name to IP", "NETBIOS-NAME" },
979 { "WINS-by-ip", 'I', POPT_ARG_STRING, &string_arg, 'I', "Converts IP address to NetBIOS name", "IP" },
980 { "name-to-sid", 'n', POPT_ARG_STRING, &string_arg, 'n', "Converts name to sid", "NAME" },
981 { "sid-to-name", 's', POPT_ARG_STRING, &string_arg, 's', "Converts sid to name", "SID" },
982 { "uid-to-sid", 'U', POPT_ARG_INT, &int_arg, 'U', "Converts uid to sid" , "UID" },
983 { "gid-to-sid", 'G', POPT_ARG_INT, &int_arg, 'G', "Converts gid to sid", "GID" },
984 { "sid-to-uid", 'S', POPT_ARG_STRING, &string_arg, 'S', "Converts sid to uid", "SID" },
985 { "sid-to-gid", 'Y', POPT_ARG_STRING, &string_arg, 'Y', "Converts sid to gid", "SID" },
986 { "allocate-rid", 'A', POPT_ARG_NONE, 0, 'A', "Get a new RID out of idmap" },
987 { "check-secret", 't', POPT_ARG_NONE, 0, 't', "Check shared secret" },
988 { "trusted-domains", 'm', POPT_ARG_NONE, 0, 'm', "List trusted domains" },
989 { "sequence", 0, POPT_ARG_NONE, 0, OPT_SEQUENCE, "Show sequence numbers of all domains" },
990 { "domain-info", 'D', POPT_ARG_STRING, &string_arg, 'D', "Show most of the info we have about the domain" },
991 { "user-groups", 'r', POPT_ARG_STRING, &string_arg, 'r', "Get user groups", "USER" },
992 { "user-domgroups", 0, POPT_ARG_STRING, &string_arg,
993 OPT_USERDOMGROUPS, "Get user domain groups", "SID" },
994 { "user-sids", 0, POPT_ARG_STRING, &string_arg, OPT_USERSIDS, "Get user group sids for user SID", "SID" },
995 { "authenticate", 'a', POPT_ARG_STRING, &string_arg, 'a', "authenticate user", "user%password" },
996 { "set-auth-user", 0, POPT_ARG_STRING, &string_arg, OPT_SET_AUTH_USER, "Store user and password used by winbindd (root only)", "user%password" },
997 { "getdcname", 0, POPT_ARG_STRING, &string_arg, OPT_GETDCNAME,
998 "Get a DC name for a foreign domain", "domainname" },
999 { "get-auth-user", 0, POPT_ARG_NONE, NULL, OPT_GET_AUTH_USER, "Retrieve user and password used by winbindd (root only)", NULL },
1000 { "ping", 'p', POPT_ARG_NONE, 0, 'p', "Ping winbindd to see if it is alive" },
1001 { "domain", 0, POPT_ARG_STRING, &opt_domain_name, OPT_DOMAIN_NAME, "Define to the domain to restrict operation", "domain" },
1002 #ifdef WITH_FAKE_KASERVER
1003 { "klog", 'k', POPT_ARG_STRING, &string_arg, 'k', "set an AFS token from winbind", "user%password" },
1009 /* Samba client initialisation */
1011 if (!lp_load(dyn_CONFIGFILE, True, False, False)) {
1012 d_fprintf(stderr, "wbinfo: error opening config file %s. Error was %s\n",
1013 dyn_CONFIGFILE, strerror(errno));
1024 pc = poptGetContext("wbinfo", argc, (const char **)argv, long_options, 0);
1026 /* Parse command line options */
1029 poptPrintHelp(pc, stderr, 0);
1033 while((opt = poptGetNextOpt(pc)) != -1) {
1034 /* get the generic configuration parameters like --domain */
1037 poptFreeContext(pc);
1039 pc = poptGetContext(NULL, argc, (const char **)argv, long_options,
1040 POPT_CONTEXT_KEEP_FIRST);
1042 while((opt = poptGetNextOpt(pc)) != -1) {
1045 if (!print_domain_users(opt_domain_name)) {
1046 d_printf("Error looking up domain users\n");
1051 if (!print_domain_groups(opt_domain_name)) {
1052 d_printf("Error looking up domain groups\n");
1057 if (!wbinfo_lookupsid(string_arg)) {
1058 d_printf("Could not lookup sid %s\n", string_arg);
1063 if (!wbinfo_lookupname(string_arg)) {
1064 d_printf("Could not lookup name %s\n", string_arg);
1069 if (!wbinfo_wins_byname(string_arg)) {
1070 d_printf("Could not lookup WINS by name %s\n", string_arg);
1075 if (!wbinfo_wins_byip(string_arg)) {
1076 d_printf("Could not lookup WINS by IP %s\n", string_arg);
1081 if (!wbinfo_uid_to_sid(int_arg)) {
1082 d_printf("Could not convert uid %d to sid\n", int_arg);
1087 if (!wbinfo_gid_to_sid(int_arg)) {
1088 d_printf("Could not convert gid %d to sid\n",
1094 if (!wbinfo_sid_to_uid(string_arg)) {
1095 d_printf("Could not convert sid %s to uid\n",
1101 if (!wbinfo_sid_to_gid(string_arg)) {
1102 d_printf("Could not convert sid %s to gid\n",
1108 if (!wbinfo_allocate_rid()) {
1109 d_printf("Could not allocate a RID\n");
1114 if (!wbinfo_check_secret()) {
1115 d_printf("Could not check secret\n");
1120 if (!wbinfo_list_domains()) {
1121 d_printf("Could not list trusted domains\n");
1126 if (!wbinfo_show_sequence(opt_domain_name)) {
1127 d_printf("Could not show sequence numbers\n");
1132 if (!wbinfo_domain_info(string_arg)) {
1133 d_printf("Could not get domain info\n");
1138 if (!wbinfo_get_usergroups(string_arg)) {
1139 d_printf("Could not get groups for user %s\n",
1145 if (!wbinfo_get_usersids(string_arg)) {
1146 d_printf("Could not get group SIDs for user SID %s\n",
1151 case OPT_USERDOMGROUPS:
1152 if (!wbinfo_get_userdomgroups(string_arg)) {
1153 d_printf("Could not get user's domain groups "
1154 "for user SID %s\n", string_arg);
1159 BOOL got_error = False;
1161 if (!wbinfo_auth(string_arg)) {
1162 d_printf("Could not authenticate user %s with "
1163 "plaintext password\n", string_arg);
1167 if (!wbinfo_auth_crap(string_arg)) {
1168 d_printf("Could not authenticate user %s with "
1169 "challenge/response\n", string_arg);
1178 if (!wbinfo_klog(string_arg)) {
1179 d_printf("Could not klog user\n");
1184 if (!wbinfo_ping()) {
1185 d_printf("could not ping winbindd!\n");
1189 case OPT_SET_AUTH_USER:
1190 wbinfo_set_auth_user(string_arg);
1192 case OPT_GET_AUTH_USER:
1193 wbinfo_get_auth_user();
1196 wbinfo_getdcname(string_arg);
1198 /* generic configuration options */
1199 case OPT_DOMAIN_NAME:
1202 d_fprintf(stderr, "Invalid option\n");
1203 poptPrintHelp(pc, stderr, 0);
1213 poptFreeContext(pc);