2 Unix SMB/Netbios implementation.
5 Winbind authentication mechnism
7 Copyright (C) Tim Potter 2000
8 Copyright (C) Andrew Bartlett 2001
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 2 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, write to the Free Software
22 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
27 /* Prototypes from common.h */
29 NSS_STATUS winbindd_request(int req_type,
30 struct winbindd_request *request,
31 struct winbindd_response *response);
34 /* Authenticate a user with a challenge/response */
36 static NTSTATUS check_winbind_security(const struct auth_context *auth_context,
37 void *my_private_data,
39 const auth_usersupplied_info *user_info,
40 auth_serversupplied_info **server_info)
42 struct winbindd_request request;
43 struct winbindd_response response;
49 return NT_STATUS_UNSUCCESSFUL;
53 DEBUG(3,("Password for user %s cannot be checked because we have no auth_info to get the challenge from.\n",
54 user_info->internal_username.str));
55 return NT_STATUS_UNSUCCESSFUL;
58 /* Send off request */
61 ZERO_STRUCT(response);
63 snprintf(request.data.auth_crap.user, sizeof(request.data.auth_crap.user),
64 "%s\\%s", user_info->domain.str, user_info->smb_name.str);
66 memcpy(request.data.auth_crap.chal, auth_context->challenge.data, sizeof(request.data.auth_crap.chal));
68 request.data.auth_crap.lm_resp_len = MIN(user_info->lm_resp.length,
69 sizeof(request.data.auth_crap.lm_resp));
70 request.data.auth_crap.nt_resp_len = MIN(user_info->nt_resp.length,
71 sizeof(request.data.auth_crap.nt_resp));
73 memcpy(request.data.auth_crap.lm_resp, user_info->lm_resp.data,
74 sizeof(request.data.auth_crap.lm_resp_len));
75 memcpy(request.data.auth_crap.nt_resp, user_info->nt_resp.data,
76 request.data.auth_crap.lm_resp_len);
78 result = winbindd_request(WINBINDD_PAM_AUTH_CRAP, &request, &response);
80 if (result == NSS_STATUS_SUCCESS) {
82 pw = Get_Pwnam(user_info->internal_username.str);
85 if (make_server_info_pw(server_info, pw)) {
86 nt_status = NT_STATUS_OK;
88 nt_status = NT_STATUS_NO_MEMORY;
91 nt_status = NT_STATUS_NO_SUCH_USER;
94 nt_status = NT_STATUS_LOGON_FAILURE;
100 /* module initialisation */
101 BOOL auth_init_winbind(struct auth_context *auth_context, auth_methods **auth_method)
103 if (!make_auth_methods(auth_context, auth_method)) {
107 (*auth_method)->auth = check_winbind_security;