2 Unix SMB/CIFS implementation.
6 Copyright (C) Simo Sorce 2005
7 Copyright (C) Andrew Tridgell 2005
8 Copyright (C) Andrew Bartlett 2005
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/>.
25 #include "auth/auth.h"
28 It's allowed to pass NULL as session_info,
29 when the caller doesn't need a session_info
31 _PUBLIC_ NTSTATUS
authenticate_username_pw(TALLOC_CTX
*mem_ctx
,
32 struct tevent_context
*ev
,
33 struct imessaging_context
*msg
,
34 struct loadparm_context
*lp_ctx
,
35 const char *nt4_domain
,
36 const char *nt4_username
,
38 const uint32_t logon_parameters
,
39 struct auth_session_info
**session_info
)
41 struct auth4_context
*auth_context
;
42 struct auth_usersupplied_info
*user_info
;
43 struct auth_user_info_dc
*user_info_dc
;
45 TALLOC_CTX
*tmp_ctx
= talloc_new(mem_ctx
);
48 return NT_STATUS_NO_MEMORY
;
51 nt_status
= auth_context_create(tmp_ctx
,
55 if (!NT_STATUS_IS_OK(nt_status
)) {
60 user_info
= talloc_zero(tmp_ctx
, struct auth_usersupplied_info
);
63 return NT_STATUS_NO_MEMORY
;
66 user_info
->mapped_state
= true;
67 user_info
->client
.account_name
= nt4_username
;
68 user_info
->mapped
.account_name
= nt4_username
;
69 user_info
->client
.domain_name
= nt4_domain
;
70 user_info
->mapped
.domain_name
= nt4_domain
;
72 user_info
->workstation_name
= NULL
;
74 user_info
->remote_host
= NULL
;
76 user_info
->password_state
= AUTH_PASSWORD_PLAIN
;
77 user_info
->password
.plaintext
= talloc_strdup(user_info
, password
);
79 user_info
->flags
= USER_INFO_CASE_INSENSITIVE_USERNAME
|
80 USER_INFO_DONT_CHECK_UNIX_ACCOUNT
;
82 user_info
->logon_parameters
= logon_parameters
|
83 MSV1_0_CLEARTEXT_PASSWORD_ALLOWED
|
84 MSV1_0_CLEARTEXT_PASSWORD_SUPPLIED
;
86 nt_status
= auth_check_password(auth_context
, tmp_ctx
, user_info
, &user_info_dc
);
87 if (!NT_STATUS_IS_OK(nt_status
)) {
93 uint32_t flags
= AUTH_SESSION_INFO_DEFAULT_GROUPS
;
94 if (user_info_dc
->info
->authenticated
) {
95 flags
|= AUTH_SESSION_INFO_AUTHENTICATED
;
97 nt_status
= auth_context
->generate_session_info(auth_context
,
104 if (NT_STATUS_IS_OK(nt_status
)) {
105 talloc_steal(mem_ctx
, *session_info
);
109 talloc_free(tmp_ctx
);