2 Unix SMB/CIFS implementation.
3 Standardised Authentication types
4 Copyright (C) Andrew Bartlett 2001
5 Copyright (C) Stefan Metzmacher 2005
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 3 of the License, or
10 (at your option) any later version.
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this program. If not, see <http://www.gnu.org/licenses/>.
24 #include "librpc/gen_ndr/ndr_krb5pac.h"
26 extern const char *user_attrs
[];
28 union netr_Validation
;
29 struct netr_SamBaseInfo
;
31 struct loadparm_context
;
33 /* modules can use the following to determine if the interface has changed
34 * please increment the version number after each interface change
35 * with a comment and maybe update struct auth_critical_sizes.
37 /* version 1 - version from samba 3.0 - metze */
38 /* version 2 - initial samba4 version - metze */
39 /* version 3 - subsequent samba4 version - abartlet */
40 /* version 4 - subsequent samba4 version - metze */
41 /* version 0 - till samba4 is stable - metze */
42 #define AUTH_INTERFACE_VERSION 0
44 #define USER_INFO_CASE_INSENSITIVE_USERNAME 0x01 /* username may be in any case */
45 #define USER_INFO_CASE_INSENSITIVE_PASSWORD 0x02 /* password may be in any case */
46 #define USER_INFO_DONT_CHECK_UNIX_ACCOUNT 0x04 /* dont check unix account status */
47 #define USER_INFO_INTERACTIVE_LOGON 0x08 /* dont check unix account status */
49 enum auth_password_state
{
50 AUTH_PASSWORD_RESPONSE
,
55 struct auth_usersupplied_info
57 const char *workstation_name
;
58 struct socket_address
*remote_host
;
60 uint32_t logon_parameters
;
63 /* the values the client gives us */
65 const char *account_name
;
66 const char *domain_name
;
69 enum auth_password_state password_state
;
77 struct samr_Password
*lanman
;
78 struct samr_Password
*nt
;
86 struct auth_serversupplied_info
88 struct dom_sid
*account_sid
;
89 struct dom_sid
*primary_group_sid
;
91 size_t n_domain_groups
;
92 struct dom_sid
**domain_groups
;
94 DATA_BLOB user_session_key
;
95 DATA_BLOB lm_session_key
;
97 const char *account_name
;
98 const char *domain_name
;
100 const char *full_name
;
101 const char *logon_script
;
102 const char *profile_path
;
103 const char *home_directory
;
104 const char *home_drive
;
105 const char *logon_server
;
110 NTTIME last_password_change
;
111 NTTIME allow_password_change
;
112 NTTIME force_password_change
;
114 uint16_t logon_count
;
115 uint16_t bad_password_count
;
121 struct PAC_SIGNATURE_DATA pac_srv_sig
, pac_kdc_sig
;
124 struct auth_method_context
;
125 struct auth_check_password_request
;
128 struct auth_operations
{
131 /* If you are using this interface, then you are probably
132 * getting something wrong. This interface is only for
133 * security=server, and makes a number of compromises to allow
134 * that. It is not compatible with being a PDC. */
136 NTSTATUS (*get_challenge
)(struct auth_method_context
*ctx
, TALLOC_CTX
*mem_ctx
, DATA_BLOB
*challenge
);
138 /* Given the user supplied info, check if this backend want to handle the password checking */
140 NTSTATUS (*want_check
)(struct auth_method_context
*ctx
, TALLOC_CTX
*mem_ctx
,
141 const struct auth_usersupplied_info
*user_info
);
143 /* Given the user supplied info, check a password */
145 NTSTATUS (*check_password
)(struct auth_method_context
*ctx
, TALLOC_CTX
*mem_ctx
,
146 const struct auth_usersupplied_info
*user_info
,
147 struct auth_serversupplied_info
**server_info
);
149 /* Lookup a 'server info' return based only on the principal */
150 NTSTATUS (*get_server_info_principal
)(TALLOC_CTX
*mem_ctx
,
151 struct auth_context
*auth_context
,
152 const char *principal
,
153 struct auth_serversupplied_info
**server_info
);
156 struct auth_method_context
{
157 struct auth_method_context
*prev
, *next
;
158 struct auth_context
*auth_ctx
;
159 const struct auth_operations
*ops
;
164 struct auth_context
{
166 /* Who set this up in the first place? */
169 bool may_be_modified
;
174 /* methods, in the order they should be called */
175 struct auth_method_context
*methods
;
177 /* the event context to use for calls that can block */
178 struct tevent_context
*event_ctx
;
180 /* the messaging context which can be used by backends */
181 struct messaging_context
*msg_ctx
;
183 /* loadparm context */
184 struct loadparm_context
*lp_ctx
;
186 NTSTATUS (*check_password
)(struct auth_context
*auth_ctx
,
188 const struct auth_usersupplied_info
*user_info
,
189 struct auth_serversupplied_info
**server_info
);
191 NTSTATUS (*get_challenge
)(struct auth_context
*auth_ctx
, const uint8_t **_chal
);
193 bool (*challenge_may_be_modified
)(struct auth_context
*auth_ctx
);
195 NTSTATUS (*set_challenge
)(struct auth_context
*auth_ctx
, const uint8_t chal
[8], const char *set_by
);
197 NTSTATUS (*get_server_info_principal
)(TALLOC_CTX
*mem_ctx
,
198 struct auth_context
*auth_context
,
199 const char *principal
,
200 struct auth_serversupplied_info
**server_info
);
204 /* this structure is used by backends to determine the size of some critical types */
205 struct auth_critical_sizes
{
206 int interface_version
;
207 int sizeof_auth_operations
;
208 int sizeof_auth_methods
;
209 int sizeof_auth_context
;
210 int sizeof_auth_usersupplied_info
;
211 int sizeof_auth_serversupplied_info
;
214 NTSTATUS
encrypt_user_info(TALLOC_CTX
*mem_ctx
, struct auth_context
*auth_context
,
215 enum auth_password_state to_state
,
216 const struct auth_usersupplied_info
*user_info_in
,
217 const struct auth_usersupplied_info
**user_info_encrypted
);
219 #include "auth/session.h"
220 #include "auth/system_session_proto.h"
225 struct gensec_security
;
227 NTSTATUS
auth_get_challenge(struct auth_context
*auth_ctx
, const uint8_t **_chal
);
228 NTSTATUS
authsam_account_ok(TALLOC_CTX
*mem_ctx
,
229 struct ldb_context
*sam_ctx
,
230 uint32_t logon_parameters
,
231 struct ldb_dn
*domain_dn
,
232 struct ldb_message
*msg
,
233 const char *logon_workstation
,
234 const char *name_for_logs
,
235 bool allow_domain_trust
);
236 struct auth_session_info
*system_session(TALLOC_CTX
*mem_ctx
, struct loadparm_context
*lp_ctx
);
237 NTSTATUS
authsam_make_server_info(TALLOC_CTX
*mem_ctx
, struct ldb_context
*sam_ctx
,
238 const char *netbios_name
,
239 const char *domain_name
,
240 struct ldb_dn
*domain_dn
,
241 struct ldb_message
*msg
,
242 DATA_BLOB user_sess_key
, DATA_BLOB lm_sess_key
,
243 struct auth_serversupplied_info
**_server_info
);
244 NTSTATUS
auth_system_session_info(TALLOC_CTX
*parent_ctx
,
245 struct loadparm_context
*lp_ctx
,
246 struct auth_session_info
**_session_info
) ;
247 NTSTATUS
auth_nt_status_squash(NTSTATUS nt_status
);
249 NTSTATUS
auth_context_create_methods(TALLOC_CTX
*mem_ctx
, const char **methods
,
250 struct tevent_context
*ev
,
251 struct messaging_context
*msg
,
252 struct loadparm_context
*lp_ctx
,
253 struct auth_context
**auth_ctx
);
255 NTSTATUS
auth_context_create(TALLOC_CTX
*mem_ctx
,
256 struct tevent_context
*ev
,
257 struct messaging_context
*msg
,
258 struct loadparm_context
*lp_ctx
,
259 struct auth_context
**auth_ctx
);
261 NTSTATUS
auth_check_password(struct auth_context
*auth_ctx
,
263 const struct auth_usersupplied_info
*user_info
,
264 struct auth_serversupplied_info
**server_info
);
265 NTSTATUS
auth_init(void);
266 NTSTATUS
auth_register(const struct auth_operations
*ops
);
267 NTSTATUS
authenticate_username_pw(TALLOC_CTX
*mem_ctx
,
268 struct tevent_context
*ev
,
269 struct messaging_context
*msg
,
270 struct loadparm_context
*lp_ctx
,
271 const char *nt4_domain
,
272 const char *nt4_username
,
273 const char *password
,
274 struct auth_session_info
**session_info
);
275 NTSTATUS
auth_check_password_recv(struct auth_check_password_request
*req
,
277 struct auth_serversupplied_info
**server_info
);
279 void auth_check_password_send(struct auth_context
*auth_ctx
,
280 const struct auth_usersupplied_info
*user_info
,
281 void (*callback
)(struct auth_check_password_request
*req
, void *private_data
),
283 NTSTATUS
auth_context_set_challenge(struct auth_context
*auth_ctx
, const uint8_t chal
[8], const char *set_by
);
285 NTSTATUS
samba_server_gensec_start(TALLOC_CTX
*mem_ctx
,
286 struct tevent_context
*event_ctx
,
287 struct messaging_context
*msg_ctx
,
288 struct loadparm_context
*lp_ctx
,
289 struct cli_credentials
*server_credentials
,
290 const char *target_service
,
291 struct gensec_security
**gensec_context
);
293 #endif /* _SMBAUTH_H_ */