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(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(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(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
);
139 /* Convert NetBIOS name to IP */
141 static BOOL
wbinfo_wins_byname(char *name
)
143 struct winbindd_request request
;
144 struct winbindd_response response
;
146 ZERO_STRUCT(request
);
147 ZERO_STRUCT(response
);
151 fstrcpy(request
.data
.winsreq
, name
);
153 if (winbindd_request(WINBINDD_WINS_BYNAME
, &request
, &response
) !=
154 NSS_STATUS_SUCCESS
) {
158 /* Display response */
160 printf("%s\n", response
.data
.winsresp
);
165 /* Convert IP to NetBIOS name */
167 static BOOL
wbinfo_wins_byip(char *ip
)
169 struct winbindd_request request
;
170 struct winbindd_response response
;
172 ZERO_STRUCT(request
);
173 ZERO_STRUCT(response
);
177 fstrcpy(request
.data
.winsreq
, ip
);
179 if (winbindd_request(WINBINDD_WINS_BYIP
, &request
, &response
) !=
180 NSS_STATUS_SUCCESS
) {
184 /* Display response */
186 printf("%s\n", response
.data
.winsresp
);
191 /* List trusted domains */
193 static BOOL
wbinfo_list_domains(void)
195 struct winbindd_response response
;
198 ZERO_STRUCT(response
);
202 if (winbindd_request(WINBINDD_LIST_TRUSTDOM
, NULL
, &response
) !=
206 /* Display response */
208 if (response
.extra_data
) {
209 const char *extra_data
= (char *)response
.extra_data
;
211 while(next_token(&extra_data
, name
, ",", sizeof(fstring
)))
212 d_printf("%s\n", name
);
214 SAFE_FREE(response
.extra_data
);
221 /* show sequence numbers */
222 static BOOL
wbinfo_show_sequence(const char *domain
)
224 struct winbindd_request request
;
225 struct winbindd_response response
;
227 ZERO_STRUCT(response
);
228 ZERO_STRUCT(request
);
231 fstrcpy( request
.domain_name
, domain
);
235 if (winbindd_request(WINBINDD_SHOW_SEQUENCE
, &request
, &response
) !=
239 /* Display response */
241 if (response
.extra_data
) {
242 char *extra_data
= (char *)response
.extra_data
;
243 d_printf("%s", extra_data
);
244 SAFE_FREE(response
.extra_data
);
250 /* Check trust account password */
252 static BOOL
wbinfo_check_secret(void)
254 struct winbindd_response response
;
257 ZERO_STRUCT(response
);
259 result
= winbindd_request(WINBINDD_CHECK_MACHACC
, NULL
, &response
);
261 d_printf("checking the trust secret via RPC calls %s\n",
262 (result
== NSS_STATUS_SUCCESS
) ? "succeeded" : "failed");
264 if (result
!= NSS_STATUS_SUCCESS
)
265 d_printf("error code was %s (0x%x)\n",
266 response
.data
.auth
.nt_status_string
,
267 response
.data
.auth
.nt_status
);
269 return result
== NSS_STATUS_SUCCESS
;
272 /* Convert uid to sid */
274 static BOOL
wbinfo_uid_to_sid(uid_t uid
)
276 struct winbindd_request request
;
277 struct winbindd_response response
;
279 ZERO_STRUCT(request
);
280 ZERO_STRUCT(response
);
284 request
.data
.uid
= uid
;
286 if (winbindd_request(WINBINDD_UID_TO_SID
, &request
, &response
) !=
290 /* Display response */
292 d_printf("%s\n", response
.data
.sid
.sid
);
297 /* Convert gid to sid */
299 static BOOL
wbinfo_gid_to_sid(gid_t gid
)
301 struct winbindd_request request
;
302 struct winbindd_response response
;
304 ZERO_STRUCT(request
);
305 ZERO_STRUCT(response
);
309 request
.data
.gid
= gid
;
311 if (winbindd_request(WINBINDD_GID_TO_SID
, &request
, &response
) !=
315 /* Display response */
317 d_printf("%s\n", response
.data
.sid
.sid
);
322 /* Convert sid to uid */
324 static BOOL
wbinfo_sid_to_uid(char *sid
)
326 struct winbindd_request request
;
327 struct winbindd_response response
;
329 ZERO_STRUCT(request
);
330 ZERO_STRUCT(response
);
334 fstrcpy(request
.data
.sid
, sid
);
336 if (winbindd_request(WINBINDD_SID_TO_UID
, &request
, &response
) !=
340 /* Display response */
342 d_printf("%d\n", (int)response
.data
.uid
);
347 static BOOL
wbinfo_sid_to_gid(char *sid
)
349 struct winbindd_request request
;
350 struct winbindd_response response
;
352 ZERO_STRUCT(request
);
353 ZERO_STRUCT(response
);
357 fstrcpy(request
.data
.sid
, sid
);
359 if (winbindd_request(WINBINDD_SID_TO_GID
, &request
, &response
) !=
363 /* Display response */
365 d_printf("%d\n", (int)response
.data
.gid
);
370 /* Convert sid to string */
372 static BOOL
wbinfo_lookupsid(char *sid
)
374 struct winbindd_request request
;
375 struct winbindd_response response
;
377 ZERO_STRUCT(request
);
378 ZERO_STRUCT(response
);
380 /* Send off request */
382 fstrcpy(request
.data
.sid
, sid
);
384 if (winbindd_request(WINBINDD_LOOKUPSID
, &request
, &response
) !=
388 /* Display response */
390 d_printf("%s%c%s %d\n", response
.data
.name
.dom_name
,
391 winbind_separator(), response
.data
.name
.name
,
392 response
.data
.name
.type
);
397 /* Convert string to sid */
399 static BOOL
wbinfo_lookupname(char *name
)
401 struct winbindd_request request
;
402 struct winbindd_response response
;
404 /* Send off request */
406 ZERO_STRUCT(request
);
407 ZERO_STRUCT(response
);
409 parse_wbinfo_domain_user(name
, request
.data
.name
.dom_name
,
410 request
.data
.name
.name
);
412 if (winbindd_request(WINBINDD_LOOKUPNAME
, &request
, &response
) !=
416 /* Display response */
418 d_printf("%s %d\n", response
.data
.sid
.sid
, response
.data
.sid
.type
);
423 /* Authenticate a user with a plaintext password */
425 static BOOL
wbinfo_auth(char *username
)
427 struct winbindd_request request
;
428 struct winbindd_response response
;
432 /* Send off request */
434 ZERO_STRUCT(request
);
435 ZERO_STRUCT(response
);
437 p
= strchr(username
, '%');
441 fstrcpy(request
.data
.auth
.user
, username
);
442 fstrcpy(request
.data
.auth
.pass
, p
+ 1);
445 fstrcpy(request
.data
.auth
.user
, username
);
447 result
= winbindd_request(WINBINDD_PAM_AUTH
, &request
, &response
);
449 /* Display response */
451 d_printf("plaintext password authentication %s\n",
452 (result
== NSS_STATUS_SUCCESS
) ? "succeeded" : "failed");
454 if (response
.data
.auth
.nt_status
)
455 d_printf("error code was %s (0x%x)\nerror messsage was: %s\n",
456 response
.data
.auth
.nt_status_string
,
457 response
.data
.auth
.nt_status
,
458 response
.data
.auth
.error_string
);
460 return result
== NSS_STATUS_SUCCESS
;
463 /* Authenticate a user with a challenge/response */
465 static BOOL
wbinfo_auth_crap(char *username
)
467 struct winbindd_request request
;
468 struct winbindd_response response
;
475 /* Send off request */
477 ZERO_STRUCT(request
);
478 ZERO_STRUCT(response
);
480 p
= strchr(username
, '%');
484 fstrcpy(pass
, p
+ 1);
487 parse_wbinfo_domain_user(username
, name_domain
, name_user
);
489 if (push_utf8_fstring(request
.data
.auth_crap
.user
, name_user
) == -1) {
490 d_printf("unable to create utf8 string for '%s'\n",
495 if (push_utf8_fstring(request
.data
.auth_crap
.domain
,
496 name_domain
) == -1) {
497 d_printf("unable to create utf8 string for '%s'\n",
502 generate_random_buffer(request
.data
.auth_crap
.chal
, 8, False
);
504 SMBencrypt(pass
, request
.data
.auth_crap
.chal
,
505 (uchar
*)request
.data
.auth_crap
.lm_resp
);
506 SMBNTencrypt(pass
, request
.data
.auth_crap
.chal
,
507 (uchar
*)request
.data
.auth_crap
.nt_resp
);
509 request
.data
.auth_crap
.lm_resp_len
= 24;
510 request
.data
.auth_crap
.nt_resp_len
= 24;
512 result
= winbindd_request(WINBINDD_PAM_AUTH_CRAP
, &request
, &response
);
514 /* Display response */
516 d_printf("challenge/response password authentication %s\n",
517 (result
== NSS_STATUS_SUCCESS
) ? "succeeded" : "failed");
519 if (response
.data
.auth
.nt_status
)
520 d_printf("error code was %s (0x%x)\nerror messsage was: %s\n",
521 response
.data
.auth
.nt_status_string
,
522 response
.data
.auth
.nt_status
,
523 response
.data
.auth
.error_string
);
525 return result
== NSS_STATUS_SUCCESS
;
528 /******************************************************************
529 create a winbindd user
530 ******************************************************************/
532 static BOOL
wbinfo_create_user(char *username
)
534 struct winbindd_request request
;
535 struct winbindd_response response
;
538 /* Send off request */
540 ZERO_STRUCT(request
);
541 ZERO_STRUCT(response
);
543 request
.flags
= WBFLAG_ALLOCATE_RID
;
544 fstrcpy(request
.data
.acct_mgt
.username
, username
);
546 result
= winbindd_request(WINBINDD_CREATE_USER
, &request
, &response
);
548 if ( result
== NSS_STATUS_SUCCESS
)
549 d_printf("New RID is %d\n", response
.data
.rid
);
551 return result
== NSS_STATUS_SUCCESS
;
554 /******************************************************************
555 remove a winbindd user
556 ******************************************************************/
558 static BOOL
wbinfo_delete_user(char *username
)
560 struct winbindd_request request
;
561 struct winbindd_response response
;
564 /* Send off request */
566 ZERO_STRUCT(request
);
567 ZERO_STRUCT(response
);
569 fstrcpy(request
.data
.acct_mgt
.username
, username
);
571 result
= winbindd_request(WINBINDD_DELETE_USER
, &request
, &response
);
573 return result
== NSS_STATUS_SUCCESS
;
576 /******************************************************************
577 create a winbindd group
578 ******************************************************************/
580 static BOOL
wbinfo_create_group(char *groupname
)
582 struct winbindd_request request
;
583 struct winbindd_response response
;
586 /* Send off request */
588 ZERO_STRUCT(request
);
589 ZERO_STRUCT(response
);
591 fstrcpy(request
.data
.acct_mgt
.groupname
, groupname
);
593 result
= winbindd_request(WINBINDD_CREATE_GROUP
, &request
, &response
);
595 return result
== NSS_STATUS_SUCCESS
;
598 /******************************************************************
599 remove a winbindd group
600 ******************************************************************/
602 static BOOL
wbinfo_delete_group(char *groupname
)
604 struct winbindd_request request
;
605 struct winbindd_response response
;
608 /* Send off request */
610 ZERO_STRUCT(request
);
611 ZERO_STRUCT(response
);
613 fstrcpy(request
.data
.acct_mgt
.groupname
, groupname
);
615 result
= winbindd_request(WINBINDD_DELETE_GROUP
, &request
, &response
);
617 return result
== NSS_STATUS_SUCCESS
;
620 /******************************************************************
621 parse a string in the form user:group
622 ******************************************************************/
624 static BOOL
parse_user_group( const char *string
, fstring user
, fstring group
)
631 if ( !(p
= strchr( string
, ':' )) )
637 fstrcpy( user
, string
);
643 /******************************************************************
644 add a user to a winbindd group
645 ******************************************************************/
647 static BOOL
wbinfo_add_user_to_group(char *string
)
649 struct winbindd_request request
;
650 struct winbindd_response response
;
653 /* Send off request */
655 ZERO_STRUCT(request
);
656 ZERO_STRUCT(response
);
658 if ( !parse_user_group( string
, request
.data
.acct_mgt
.username
,
659 request
.data
.acct_mgt
.groupname
))
661 d_printf("Can't parse user:group from %s\n", string
);
665 result
= winbindd_request(WINBINDD_ADD_USER_TO_GROUP
, &request
, &response
);
667 return result
== NSS_STATUS_SUCCESS
;
670 /******************************************************************
671 remove a user from a winbindd group
672 ******************************************************************/
674 static BOOL
wbinfo_remove_user_from_group(char *string
)
676 struct winbindd_request request
;
677 struct winbindd_response response
;
680 /* Send off request */
682 ZERO_STRUCT(request
);
683 ZERO_STRUCT(response
);
685 if ( !parse_user_group( string
, request
.data
.acct_mgt
.username
,
686 request
.data
.acct_mgt
.groupname
))
688 d_printf("Can't parse user:group from %s\n", string
);
692 result
= winbindd_request(WINBINDD_REMOVE_USER_FROM_GROUP
, &request
, &response
);
694 return result
== NSS_STATUS_SUCCESS
;
697 /* Print domain users */
699 static BOOL
print_domain_users(const char *domain
)
701 struct winbindd_request request
;
702 struct winbindd_response response
;
703 const char *extra_data
;
706 /* Send request to winbind daemon */
708 ZERO_STRUCT(request
);
709 ZERO_STRUCT(response
);
712 /* '.' is the special sign for our own domwin */
713 if ( strequal(domain
, ".") )
714 fstrcpy( request
.domain_name
, lp_workgroup() );
716 fstrcpy( request
.domain_name
, domain
);
719 if (winbindd_request(WINBINDD_LIST_USERS
, &request
, &response
) !=
723 /* Look through extra data */
725 if (!response
.extra_data
)
728 extra_data
= (const char *)response
.extra_data
;
730 while(next_token(&extra_data
, name
, ",", sizeof(fstring
)))
731 d_printf("%s\n", name
);
733 SAFE_FREE(response
.extra_data
);
738 /* Print domain groups */
740 static BOOL
print_domain_groups(const char *domain
)
742 struct winbindd_request request
;
743 struct winbindd_response response
;
744 const char *extra_data
;
747 ZERO_STRUCT(request
);
748 ZERO_STRUCT(response
);
751 if ( strequal(domain
, ".") )
752 fstrcpy( request
.domain_name
, lp_workgroup() );
754 fstrcpy( request
.domain_name
, domain
);
757 if (winbindd_request(WINBINDD_LIST_GROUPS
, &request
, &response
) !=
761 /* Look through extra data */
763 if (!response
.extra_data
)
766 extra_data
= (const char *)response
.extra_data
;
768 while(next_token(&extra_data
, name
, ",", sizeof(fstring
)))
769 d_printf("%s\n", name
);
771 SAFE_FREE(response
.extra_data
);
776 /* Set the authorised user for winbindd access in secrets.tdb */
778 static BOOL
wbinfo_set_auth_user(char *username
)
781 fstring user
, domain
;
783 /* Separate into user and password */
785 parse_wbinfo_domain_user(username
, domain
, user
);
787 password
= strchr(user
, '%');
795 /* Store or remove DOMAIN\username%password in secrets.tdb */
801 if (!secrets_store(SECRETS_AUTH_USER
, user
,
803 d_fprintf(stderr
, "error storing username\n");
807 /* We always have a domain name added by the
808 parse_wbinfo_domain_user() function. */
810 if (!secrets_store(SECRETS_AUTH_DOMAIN
, domain
,
811 strlen(domain
) + 1)) {
812 d_fprintf(stderr
, "error storing domain name\n");
817 secrets_delete(SECRETS_AUTH_USER
);
818 secrets_delete(SECRETS_AUTH_DOMAIN
);
823 if (!secrets_store(SECRETS_AUTH_PASSWORD
, password
,
824 strlen(password
) + 1)) {
825 d_fprintf(stderr
, "error storing password\n");
830 secrets_delete(SECRETS_AUTH_PASSWORD
);
835 static void wbinfo_get_auth_user(void)
837 char *user
, *domain
, *password
;
839 /* Lift data from secrets file */
843 user
= secrets_fetch(SECRETS_AUTH_USER
, NULL
);
844 domain
= secrets_fetch(SECRETS_AUTH_DOMAIN
, NULL
);
845 password
= secrets_fetch(SECRETS_AUTH_PASSWORD
, NULL
);
847 if (!user
&& !domain
&& !password
) {
848 d_printf("No authorised user configured\n");
852 /* Pretty print authorised user info */
854 d_printf("%s%s%s%s%s\n", domain
? domain
: "", domain
? "\\" : "",
855 user
, password
? "%" : "", password
? password
: "");
862 static BOOL
wbinfo_ping(void)
866 result
= winbindd_request(WINBINDD_PING
, NULL
, NULL
);
868 /* Display response */
870 d_printf("Ping to winbindd %s on fd %d\n",
871 (result
== NSS_STATUS_SUCCESS
) ? "succeeded" : "failed", winbindd_fd
);
873 return result
== NSS_STATUS_SUCCESS
;
879 OPT_SET_AUTH_USER
= 1000,
885 int main(int argc
, char **argv
)
890 static char *string_arg
;
891 static char *opt_domain_name
;
895 struct poptOption long_options
[] = {
898 /* longName, shortName, argInfo, argPtr, value, descrip,
901 { "domain-users", 'u', POPT_ARG_NONE
, 0, 'u', "Lists all domain users", "domain"},
902 { "domain-groups", 'g', POPT_ARG_NONE
, 0, 'g', "Lists all domain groups", "domain" },
903 { "WINS-by-name", 'N', POPT_ARG_STRING
, &string_arg
, 'N', "Converts NetBIOS name to IP", "NETBIOS-NAME" },
904 { "WINS-by-ip", 'I', POPT_ARG_STRING
, &string_arg
, 'I', "Converts IP address to NetBIOS name", "IP" },
905 { "name-to-sid", 'n', POPT_ARG_STRING
, &string_arg
, 'n', "Converts name to sid", "NAME" },
906 { "sid-to-name", 's', POPT_ARG_STRING
, &string_arg
, 's', "Converts sid to name", "SID" },
907 { "uid-to-sid", 'U', POPT_ARG_INT
, &int_arg
, 'U', "Converts uid to sid" , "UID" },
908 { "gid-to-sid", 'G', POPT_ARG_INT
, &int_arg
, 'G', "Converts gid to sid", "GID" },
909 { "sid-to-uid", 'S', POPT_ARG_STRING
, &string_arg
, 'S', "Converts sid to uid", "SID" },
910 { "sid-to-gid", 'Y', POPT_ARG_STRING
, &string_arg
, 'Y', "Converts sid to gid", "SID" },
911 { "create-user", 'c', POPT_ARG_STRING
, &string_arg
, 'c', "Create a local user account", "name" },
912 { "delete-user", 'x', POPT_ARG_STRING
, &string_arg
, 'x', "Delete a local user account", "name" },
913 { "create-group", 'C', POPT_ARG_STRING
, &string_arg
, 'C', "Create a local group", "name" },
914 { "delete-group", 'X', POPT_ARG_STRING
, &string_arg
, 'X', "Delete a local group", "name" },
915 { "add-to-group", 'o', POPT_ARG_STRING
, &string_arg
, 'o', "Add user to group", "user:group" },
916 { "del-from-group", 'O', POPT_ARG_STRING
, &string_arg
, 'O', "Remove user from group", "user:group" },
917 { "check-secret", 't', POPT_ARG_NONE
, 0, 't', "Check shared secret" },
918 { "trusted-domains", 'm', POPT_ARG_NONE
, 0, 'm', "List trusted domains" },
919 { "sequence", 0, POPT_ARG_NONE
, 0, OPT_SEQUENCE
, "Show sequence numbers of all domains" },
920 { "user-groups", 'r', POPT_ARG_STRING
, &string_arg
, 'r', "Get user groups", "USER" },
921 { "authenticate", 'a', POPT_ARG_STRING
, &string_arg
, 'a', "authenticate user", "user%password" },
922 { "set-auth-user", 0, POPT_ARG_STRING
, &string_arg
, OPT_SET_AUTH_USER
, "Store user and password used by winbindd (root only)", "user%password" },
923 { "get-auth-user", 0, POPT_ARG_NONE
, NULL
, OPT_GET_AUTH_USER
, "Retrieve user and password used by winbindd (root only)", NULL
},
924 { "ping", 'p', POPT_ARG_NONE
, 0, 'p', "Ping winbindd to see if it is alive" },
925 { "domain", 0, POPT_ARG_STRING
, &opt_domain_name
, OPT_DOMAIN_NAME
, "Define to the domain to restrict operatio", "domain" },
930 /* Samba client initialisation */
932 if (!lp_load(dyn_CONFIGFILE
, True
, False
, False
)) {
933 d_fprintf(stderr
, "wbinfo: error opening config file %s. Error was %s\n",
934 dyn_CONFIGFILE
, strerror(errno
));
945 pc
= poptGetContext("wbinfo", argc
, (const char **)argv
, long_options
, 0);
947 /* Parse command line options */
950 poptPrintHelp(pc
, stderr
, 0);
954 while((opt
= poptGetNextOpt(pc
)) != -1) {
955 /* get the generic configuration parameters like --domain */
960 pc
= poptGetContext(NULL
, argc
, (const char **)argv
, long_options
,
961 POPT_CONTEXT_KEEP_FIRST
);
963 while((opt
= poptGetNextOpt(pc
)) != -1) {
966 if (!print_domain_users(opt_domain_name
)) {
967 d_printf("Error looking up domain users\n");
972 if (!print_domain_groups(opt_domain_name
)) {
973 d_printf("Error looking up domain groups\n");
978 if (!wbinfo_lookupsid(string_arg
)) {
979 d_printf("Could not lookup sid %s\n", string_arg
);
984 if (!wbinfo_lookupname(string_arg
)) {
985 d_printf("Could not lookup name %s\n", string_arg
);
990 if (!wbinfo_wins_byname(string_arg
)) {
991 d_printf("Could not lookup WINS by name %s\n", string_arg
);
996 if (!wbinfo_wins_byip(string_arg
)) {
997 d_printf("Could not lookup WINS by IP %s\n", string_arg
);
1002 if (!wbinfo_uid_to_sid(int_arg
)) {
1003 d_printf("Could not convert uid %d to sid\n", int_arg
);
1008 if (!wbinfo_gid_to_sid(int_arg
)) {
1009 d_printf("Could not convert gid %d to sid\n",
1015 if (!wbinfo_sid_to_uid(string_arg
)) {
1016 d_printf("Could not convert sid %s to uid\n",
1022 if (!wbinfo_sid_to_gid(string_arg
)) {
1023 d_printf("Could not convert sid %s to gid\n",
1029 if (!wbinfo_check_secret()) {
1030 d_printf("Could not check secret\n");
1035 if (!wbinfo_list_domains()) {
1036 d_printf("Could not list trusted domains\n");
1041 if (!wbinfo_show_sequence(opt_domain_name
)) {
1042 d_printf("Could not show sequence numbers\n");
1047 if (!wbinfo_get_usergroups(string_arg
)) {
1048 d_printf("Could not get groups for user %s\n",
1054 BOOL got_error
= False
;
1056 if (!wbinfo_auth(string_arg
)) {
1057 d_printf("Could not authenticate user %s with "
1058 "plaintext password\n", string_arg
);
1062 if (!wbinfo_auth_crap(string_arg
)) {
1063 d_printf("Could not authenticate user %s with "
1064 "challenge/response\n", string_arg
);
1073 if ( !wbinfo_create_user(string_arg
) ) {
1074 d_printf("Could not create user account\n");
1079 if ( !wbinfo_create_group(string_arg
) ) {
1080 d_printf("Could not create group\n");
1085 if ( !wbinfo_add_user_to_group(string_arg
) ) {
1086 d_printf("Could not add user to group\n");
1091 if ( !wbinfo_remove_user_from_group(string_arg
) ) {
1092 d_printf("Could not remove user kfrom group\n");
1097 if ( !wbinfo_delete_user(string_arg
) ) {
1098 d_printf("Could not delete user account\n");
1103 if ( !wbinfo_delete_group(string_arg
) ) {
1104 d_printf("Could not delete group\n");
1109 if (!wbinfo_ping()) {
1110 d_printf("could not ping winbindd!\n");
1114 case OPT_SET_AUTH_USER
:
1115 wbinfo_set_auth_user(string_arg
);
1117 case OPT_GET_AUTH_USER
:
1118 wbinfo_get_auth_user();
1120 /* generic configuration options */
1121 case OPT_DOMAIN_NAME
:
1124 d_fprintf(stderr
, "Invalid option\n");
1125 poptPrintHelp(pc
, stderr
, 0);
1135 poptFreeContext(pc
);