2 Unix SMB/CIFS implementation.
4 Winbind daemon - user related functions
6 Copyright (C) Tim Potter 2000
7 Copyright (C) Jeremy Allison 2001.
8 Copyright (C) Gerald (Jerry) Carter 2003.
10 This program is free software; you can redistribute it and/or modify
11 it under the terms of the GNU General Public License as published by
12 the Free Software Foundation; either version 3 of the License, or
13 (at your option) any later version.
15 This program is distributed in the hope that it will be useful,
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 GNU General Public License for more details.
20 You should have received a copy of the GNU General Public License
21 along with this program. If not, see <http://www.gnu.org/licenses/>.
28 #define DBGC_CLASS DBGC_WINBIND
30 bool fillup_pw_field(const char *lp_template
,
43 /* The substitution of %U and %D in the 'template
44 homedir' is done by talloc_sub_specified() below.
45 If we have an in string (which means the value has already
46 been set in the nss_info backend), then use that.
47 Otherwise use the template value passed in. */
49 if ( in
&& !strequal(in
,"") && lp_security() == SEC_ADS
) {
50 templ
= talloc_sub_specified(NULL
, in
,
54 templ
= talloc_sub_specified(NULL
, lp_template
,
62 safe_strcpy(out
, templ
, sizeof(fstring
) - 1);
69 /* Wrapper for domain->methods->query_user, only on the parent->child pipe */
71 enum winbindd_result
winbindd_dual_userinfo(struct winbindd_domain
*domain
,
72 struct winbindd_cli_state
*state
)
75 struct wbint_userinfo user_info
;
78 /* Ensure null termination */
79 state
->request
->data
.sid
[sizeof(state
->request
->data
.sid
)-1]='\0';
81 DEBUG(3, ("[%5lu]: lookupsid %s\n", (unsigned long)state
->pid
,
82 state
->request
->data
.sid
));
84 if (!string_to_sid(&sid
, state
->request
->data
.sid
)) {
85 DEBUG(5, ("%s not a SID\n", state
->request
->data
.sid
));
86 return WINBINDD_ERROR
;
89 status
= domain
->methods
->query_user(domain
, state
->mem_ctx
,
91 if (!NT_STATUS_IS_OK(status
)) {
92 DEBUG(1, ("error getting user info for sid %s\n",
93 sid_string_dbg(&sid
)));
94 return WINBINDD_ERROR
;
97 fstrcpy(state
->response
->data
.user_info
.acct_name
,
99 fstrcpy(state
->response
->data
.user_info
.full_name
,
100 user_info
.full_name
);
101 fstrcpy(state
->response
->data
.user_info
.homedir
, user_info
.homedir
);
102 fstrcpy(state
->response
->data
.user_info
.shell
, user_info
.shell
);
103 state
->response
->data
.user_info
.primary_gid
= user_info
.primary_gid
;
104 if (!sid_peek_check_rid(&domain
->sid
, &user_info
.group_sid
,
105 &state
->response
->data
.user_info
.group_rid
)) {
106 DEBUG(1, ("Could not extract group rid out of %s\n",
107 sid_string_dbg(&sid
)));
108 return WINBINDD_ERROR
;
114 /* List domain users without mapping to unix ids */
115 void winbindd_list_users(struct winbindd_cli_state
*state
)
117 winbindd_list_ent(state
, LIST_USERS
);